S
Stephen Lynch
In access, I have code that adds data from the database via a query to an
excel file. I now need to password protect the file and I am having trouble
password protecting my excel workbook via script. Any help is appreciated:
Here is my code:
Dim ExcelApp As Excel.Application
Dim workBook As Object
Dim workSheet As Object
Set ExcelApp = CreateObject("Excel.Application")
ExcelApp.Visible = True
ExcelApp.Workbooks.Open ("S:\test.xls")
ExcelApp.Cells.Select
ExcelApp.Selection.Columns.AutoFit
ExcelApp.Application.DisplayAlerts = False
ExcelApp.Application.Save
ExcelApp.Application.DisplayAlerts = True
ExcelApp.Application.Quit
This runs but if I add
ExcelApp.Worksheets.Protect Password = "1234" before
ExcelApp.Application.Save I get an error. Anyone know the correct code to
add?
Thanks
excel file. I now need to password protect the file and I am having trouble
password protecting my excel workbook via script. Any help is appreciated:
Here is my code:
Dim ExcelApp As Excel.Application
Dim workBook As Object
Dim workSheet As Object
Set ExcelApp = CreateObject("Excel.Application")
ExcelApp.Visible = True
ExcelApp.Workbooks.Open ("S:\test.xls")
ExcelApp.Cells.Select
ExcelApp.Selection.Columns.AutoFit
ExcelApp.Application.DisplayAlerts = False
ExcelApp.Application.Save
ExcelApp.Application.DisplayAlerts = True
ExcelApp.Application.Quit
This runs but if I add
ExcelApp.Worksheets.Protect Password = "1234" before
ExcelApp.Application.Save I get an error. Anyone know the correct code to
add?
Thanks