Hi,
I am attempting to open a password protected .xlsm file using WorkbookOpen() in Excel 2003. Even though the password is in the WorkbookOpen() command, I am prompted to enter the password.
Data Files with passwords are all set using Tools > Options > Security > Password to Open
The password for the two password protected files is ABC.
Code excerpt that compiles and runs (but asks for Password):
Sub OpenFile_bbbPasswordIsABC_DOT_xlsm()
Dim sFileName As String
Dim sFileNamePassword As String
Dim sPath As String
Dim sPathAndFileName As String
sPath = ThisWorkbook.Path & "\"
sFileName = "bbbPasswordIsABC.xlsm"
sPathAndFileName = sPath & sFileName
sFileNamePassword = "ABC"
Workbooks.Open Filename:=sPathAndFileName, Password:=sFileNamePassword, ReadOnly:=True
End Sub
Am I doing something wrong, or is this a feature of the Microsoft .xlsm to .xls converter?
The attached .zip file contains a sample workbook and 4 sample data files:
1. OpenXlsmPasswordProtectedFileFromExcel2003.xls
2. xxx.xls
3. yyy.xlsm
4. aaaPasswordIsABC.xls
5. bbbPasswordIsABC.xlsm
Lewis
Bookmarks