ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Openning a file using the password from VBA (https://www.excelbanter.com/excel-programming/333497-openning-file-using-password-vba.html)

Ken Loomis

Openning a file using the password from VBA
 
Is there a way, given a file's path & name, to determine if it is a password
protected Excel workbook?

And, if it is a password protected workbook, can I open it from VBA using
that password, so I can modify it and save it from VBA?

Thanks,
Ken



moi

Openning a file using the password from VBA
 
Sub OpenProtectedFile()
Dim wb As Workbook
Dim ws As Worksheet
Set wb = Workbooks.Open("C:\Password Protected File.xls", , , ,
"password1", "password2")
Set ws = wb.Sheets("Sheet1")
ws.Activate
ws.Cells(1, 1).Value = "Modified by VBA"
End Sub

"Ken Loomis" schreef in bericht
...
Is there a way, given a file's path & name, to determine if it is a
password protected Excel workbook?

And, if it is a password protected workbook, can I open it from VBA using
that password, so I can modify it and save it from VBA?

Thanks,
Ken






All times are GMT +1. The time now is 05:09 PM.

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