Saving with password

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have files that I need to save with a passord each month. I'd like to
automate this as the password will be the same. The location (of all the
files) will be different each month, so using SaveAs won't help too much
unless I want to change the code each month. I tried ThisWorkbook Save and
ActiveWorkbook Save and they didn't work with Pasword. Anyione have any
thouhts?

Thanks,

Alan
 
Hi Alan,

Perhaps, try something like:

'=============>>
Public Sub Tester()
Const PWORD As String = "ABC" '<<==== CHANGE

Application.DisplayAlerts = False
With ActiveWorkbook
.SaveAs Filename:=.FullName, _
Password:=PWORD
End With
Application.DisplayAlerts = True
End Sub
'<<=============
 
How would Using SAVE rather than SAVEAS correct the problem?


There is no way for the code to know or discover the correct location?

If the workbook has already been saved and you just want to apply a password
to it, then use

Application.DisplayAlerts = False
Thisworkbook.SaveAs Thisworkbook.FullName, Password:="CouldItBeSoSimple"
Application.DisplayAlerts = True


or replace thisworkbook with activeworkbook if the book containing the code
is not the book being saved.
 

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

Back
Top