In an asp page, I call a function, ConnectXL with one argument. Argument is location/path of a macro-enabled (xlsm) excel file.
ConnectXL function is:
With this code, the connection opened successfully for the file LWP.xlsm. Then I protected the workbook LWP.xlsm as follows in Excel 2007:
Review -> Protect Workbook -> Protect Structure and Windows
Entered 123 as password, reentered 123 and clicked OK.
Now when ConnectXL reaches the following line:
it generates the following error:
External table is not in the expected format.
I am unable to connect to the workbook after applying protect workbook password.
ConnectXL function is:
Code:
sub ConnectXL(filename)
Set cnn = Server.CreateObject("ADODB.Connection")
cnstr="Provider=Microsoft.ACE.OLEDB.12.0;"
cnstr=cnstr & "Data Source=" & filename & ";"
cnstr=cnstr & "Extended Properties=""Excel 12.0 Macro;HDR=YES"";"
cnn.Open cnstr
end sub
With this code, the connection opened successfully for the file LWP.xlsm. Then I protected the workbook LWP.xlsm as follows in Excel 2007:
Review -> Protect Workbook -> Protect Structure and Windows
Entered 123 as password, reentered 123 and clicked OK.
Now when ConnectXL reaches the following line:
Code:
cnn.Open cnstr
it generates the following error:
External table is not in the expected format.
I am unable to connect to the workbook after applying protect workbook password.