ado 打开有密码的Excel文件
答案:2 悬赏:50 手机版
解决时间 2021-11-29 04:04
- 提问者网友:锁深秋
- 2021-11-28 18:04
ado 打开有密码的Excel文件
最佳答案
- 五星知识达人网友:拜訪者
- 2021-11-28 19:14
If the Excel workbook is protected by a password, you cannot open it for data access, even by supplying the correct password with your connection settings, unless the workbook file is already open in the Microsoft Excel application. If you try, you receive the following error message:
Could not decrypt file.
微软官方说不支持
但不是没有关解决方法
'Open the Excel workbook to prompt for the password
Dim xl As Object
Set xl = GetObject(CurrentProject.Path & "\" & "MASTER JAN 2009.xls")
'Now open the workbook to read/write/whatever
Dim cnn1 As New ADODB.Connection
Dim rst1 As ADODB.Recordset
Dim strExcelName As String = "MASTER JAN 2009.xls"
Dim strWkBkName As String = "[MASTER 2008$]"
cnn1.Open "Provider=Microsoft.Jet.OLEDB.4.0;" _
"Data Source=" & CurrentProject.Path & "\" & strExcelName & ";" _
"Extended Properties=""Excel 8.0;"";"
Set rst1 = New ADODB.Recordset
rst1.Open strWkBkName, cnn1, , , adCmdTable
Do Until rst1.EOF
'process your data here
rst1.MoveNext
Loop
Could not decrypt file.
微软官方说不支持
但不是没有关解决方法
'Open the Excel workbook to prompt for the password
Dim xl As Object
Set xl = GetObject(CurrentProject.Path & "\" & "MASTER JAN 2009.xls")
'Now open the workbook to read/write/whatever
Dim cnn1 As New ADODB.Connection
Dim rst1 As ADODB.Recordset
Dim strExcelName As String = "MASTER JAN 2009.xls"
Dim strWkBkName As String = "[MASTER 2008$]"
cnn1.Open "Provider=Microsoft.Jet.OLEDB.4.0;" _
"Data Source=" & CurrentProject.Path & "\" & strExcelName & ";" _
"Extended Properties=""Excel 8.0;"";"
Set rst1 = New ADODB.Recordset
rst1.Open strWkBkName, cnn1, , , adCmdTable
Do Until rst1.EOF
'process your data here
rst1.MoveNext
Loop
全部回答
- 1楼网友:不甚了了
- 2021-11-28 19:49
_bstr_t bStrUserId = "User ID=admin";
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯