ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Add Password Using Access (https://www.excelbanter.com/excel-programming/339525-add-password-using-access.html)

Ross

Add Password Using Access
 
I am try to add a password to an exported spreadsheet programmatically using
MS Access. I borrowed this code from another program and it works perpectly
except, it requires the user to enter YES to save the document.

How can I modify this code to prevent having to answer Yes to the save
changes question.

Code:
strCompleteExcelName = DestinationFolder & ExcelFileName
Set app = New Excel.Application
Set wbk = app.Workbooks.Open(FileName:=strCompleteExcelName)

With wbk

.SaveAs FileName:=DestinationFolder & ExcelFileName & ".xls", _
WriteResPassword:=ReadOnlyPassword

.Close
End With
Set wbk = Nothing

' Shut down the Excel connection.
app.Quit
Set app = Nothing

Thank you

Ross

Wolf

Add Password Using Access
 
Try perhaps

..close false

Wolf

"Ross" wrote:

I am try to add a password to an exported spreadsheet programmatically using
MS Access. I borrowed this code from another program and it works perpectly
except, it requires the user to enter YES to save the document.

How can I modify this code to prevent having to answer Yes to the save
changes question.

Code:
strCompleteExcelName = DestinationFolder & ExcelFileName
Set app = New Excel.Application
Set wbk = app.Workbooks.Open(FileName:=strCompleteExcelName)

With wbk

.SaveAs FileName:=DestinationFolder & ExcelFileName & ".xls", _
WriteResPassword:=ReadOnlyPassword

.Close
End With
Set wbk = Nothing

' Shut down the Excel connection.
app.Quit
Set app = Nothing

Thank you

Ross



All times are GMT +1. The time now is 02:41 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com