我想尝试使用ado连接和vba连接excel到excel。但问题是它给了一个错误无法找到可安装的ISAM。我试图看看其他解决方案,但同样的问题将返回。可能有一个即时通讯失踪的ActiveX控件?这里是我的代码在Excel 2007中找不到可安装的ISAM vba
Dim cN As ADODB.Connection '* Connection String
Dim RS As ADODB.Recordset '* Record Set
Dim sQuery As String '* Query String
Dim i1 As Long
Dim lMaxRow As Long '* Last Row in the Sheet
Dim iRevCol As Integer '*
Dim i3 As Integer
Set cN = New ADODB.Connection
cN.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\PC\Desktop\Excel Programming\PlayerDatabase.xlsm;Readonly=False;Extended Properties=Excel 12.0;;HDR=yes;Persist Security Info=False"
cN.ConnectionTimeout = 40
cN.Open
Set RS = New ADODB.Recordset
lMaxRow = ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row
sQuery = "Select * From [Player$]"
RS.ActiveConnection = cN
RS.Source = sQuery
RS.Open
If RS.EOF = True And RS.BOF = True Then
MsgBox ("End of File")
End If
If RS.State <> adStateClosed Then
RS.Close
End If
If Not RS Is Nothing Then Set RS = Nothing
If Not cN Is Nothing Then Set cN = Nothing
UPDATE:
现在我改变我的ConnectionString这个
cN.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\PC\Desktop\Excel Programming\PlayerDatabase.xlsm;Extended Properties='Excel 12.0 Macro;HDR=YES'"
,但它给了我错误无法更新。 数据库或对象是只读的。
,当我把只读=假
cN.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\PC\Desktop\Excel Programming\PlayerDatabase.xlsm;ReadOnly=false;Extended Properties='Excel 12.0 Macro;HDR=YES'"
它会给一个错误无法找到可安装ISAM :(
您的'ConnectionString'似乎被夸大了。转到[ConnectionStrings.Com](http://www.connectionstrings.com)并检查与您使用的环境和从中获取数据的文件相对应的正确语法。 –
在我的更新问题中,我将该连接字符串带到了您给我的网站。 – user2328935