Access Module, Saving an Excel sheet with a password

  • Thread starter Thread starter Andre L via AccessMonster.com
  • Start date Start date
A

Andre L via AccessMonster.com

Sometime ago I set up a module to open an Excel Template, refresh the sheets
and save the book to a share. Now I need to stick a password on the file to
be saved. Would anyone know the syntax? Here is the current code:

Dim xcelapp As Object
Set xcelapp = CreateObject("Excel.Application")
xcelapp.Workbooks.Open TemplateBook
xcelapp.DisplayAlerts = False
xcelapp.ActiveWorkbook.RefreshAll

xcelapp.ActiveWorkbook.SaveAs Filename:=NewBook
xcelapp.ActiveWorkbook.Close
 
Hi Andre

ActiveWorkbook.Protect "password"

Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access
(e-mail address removed)
 
I figured it was something simple---THANKS!!!
Hi Andre

ActiveWorkbook.Protect "password"

Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access
(e-mail address removed)
Sometime ago I set up a module to open an Excel Template, refresh the sheets
and save the book to a share. Now I need to stick a password on the file to
[quoted text clipped - 8 lines]
xcelapp.ActiveWorkbook.SaveAs Filename:=NewBook
xcelapp.ActiveWorkbook.Close
 
You're welcome, Andre ;)

I usually use a convoluted function to return "password" so
it is not easy to figure out if someone gets into the code
and does a search

Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access
strive4peace2006 at yahoo.com


I figured it was something simple---THANKS!!!
Hi Andre

ActiveWorkbook.Protect "password"

Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access
(e-mail address removed)

Sometime ago I set up a module to open an Excel Template, refresh the sheets
and save the book to a share. Now I need to stick a password on the file to

[quoted text clipped - 8 lines]
xcelapp.ActiveWorkbook.SaveAs Filename:=NewBook
xcelapp.ActiveWorkbook.Close
 
Back
Top