A
Aposto
I have the following routine which opens various Excel files:
Sub OpenExcelConn(conn As ADODB.Connection, rst As ADODB.Recordset, FileName
As String, SheetName As String)
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" &
FileName & ";" & "Extended Properties='Excel 8.0;HDR=Yes;IMEX=1'"
rst.CursorLocation = adUseClient
rst.Open "[" & SheetName & "$]", conn, adOpenStatic, adLockOptimistic
End Sub
I recently have added some excel files with a password and now I get the
error message "Can not Decrypt file" which is obviously because the file is
password protected.
How can I change the above code to allow for excel files which may or may
not have a password?
Sub OpenExcelConn(conn As ADODB.Connection, rst As ADODB.Recordset, FileName
As String, SheetName As String)
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" &
FileName & ";" & "Extended Properties='Excel 8.0;HDR=Yes;IMEX=1'"
rst.CursorLocation = adUseClient
rst.Open "[" & SheetName & "$]", conn, adOpenStatic, adLockOptimistic
End Sub
I recently have added some excel files with a password and now I get the
error message "Can not Decrypt file" which is obviously because the file is
password protected.
How can I change the above code to allow for excel files which may or may
not have a password?