how can I protect workbook on a drive from deletion

G

Gamez302

I am trying to see if there is a way to protect a worksheet for being deleted
on a shared drive.
 
G

Gamez302

I need my team to be able to add names in the worksheet. For the past couple
of days it has been deleted from our shared drive and all our data is lost.
I am wondering if we can put a password or anything to prevent this from
happening again.
 
G

Gord Dibben

This cannot be done through Excel.

If running WindowsXP or any NT OS you can set folder and file permissions.

See OS Help on "permissions" and then select "File and Folder Permissions"

Also look up "user Accounts"


Gord Dibben Excel MVP
 
D

Dave Peterson

And more bad news. If you could prevent the deletion of the workbook, you'd
break the way excel works.

When excel saves the file, it saves it as a temporary file with a funny name (8
characters--no extension).

If the save is successful, xl will delete the original (or rename it to its
backup name (like "backup of book1.xlk)) and if that's successful, xl will
rename the funny named file to the original's name.

So I'm not sure you could ever accomplish what you want.

Maybe a work-around. You could create a backup copy of the workbook whenever
anyone saves the workbook. I'd use the date/time as part of the filename so
that I could keep track of the most current. And every so often, I'd go into
that backup folder and clean it up (manually).

Option Explicit
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

Dim myFileName As String
Dim myFolderName As String

myFolderName = Me.Path & "\backup"

On Error Resume Next
MkDir myFolderName
On Error GoTo 0

myFileName = myFolderName & "\" & Left(Me.Name, Len(Me.Name) - 4) _
& "_" & Format(Now, "yyyymmdd_hhmmss") & ".xls"

ThisWorkbook.SaveCopyAs Filename:=myFileName

End Sub

This kind of code goes into the ThisWorkbook module.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Failing this kind of thing, I think the best thing to do is to make and keep
plenty of backups.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top