protect files

  • Thread starter Thread starter sphincer
  • Start date Start date
S

sphincer

Hi.

I need to protect and unprotect two files with a password.

For exemple :
Ctrl+p (active the macro)
umbrella (this is the password)
if this is the correct password ->
The two files: file1.xls and file2.xls are unprotected. We can modify
and save it,
and the color of the title bar becomes red (or something else which
watch me i can save the files).

and after that, i work and i save ...

Ctrl+p (to reactive the macro)
(don't need any password) ->
The two files: file1.xls and file2.xls are protected. We can modify,
but don't save.
The color of the title bar becomes normal.

Thanks for any help :)
 
I think you'll need to expand your specs for this.

You can protect a worksheet via tools|protection|protect sheet.
you can protect a workbook via tools|protection|protect workbook
You can even protect a workbook via File|SaveAs (from there the path varies with
versions)

Which level of protection do you mean?

And I don't think you can change the color of title bar without some fancy API
calls (that I couldn't/wouldn't do).

But you could change the titlebar's caption.
 
Ok,
thanks, Dave :)

Dave Peterson a écrit :
I think you'll need to expand your specs for this.

You can protect a worksheet via tools|protection|protect sheet.
you can protect a workbook via tools|protection|protect workbook
You can even protect a workbook via File|SaveAs (from there the path varies with
versions)

Which level of protection do you mean?

I want to protect a file via File/Save as

And I don't think you can change the color of title bar without some fancy API
calls (that I couldn't/wouldn't do).

But you could change the titlebar's caption.

How can I do this ?
 
I recorded a macro when I did a File|SaveAs and provided a password.

I got something like:

Activeworkbook.SaveAs Filename:="C:\My Documents\excel\book1.xls", _
FileFormat:=xlNormal, Password:="Hi", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

I could modify it to write over the existing file like this:

Option Explicit
Sub testme01()

With ActiveWorkbook
Application.DisplayAlerts = False
.SaveAs Filename:=.FullName, _
FileFormat:=xlNormal, Password:="Hi", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
Application.DisplayAlerts = True

ActiveWindow.Caption = .FullName & " Password protected"
End With

End Sub

And there are a couple of captions that you may want to read about in VBA's
help:
Application.Caption and ActiveWindow.Caption

The .displayalerts = false hides the "wanna overwrite the existing file?"
prompts.
 
Back
Top