VBA生成“自动化错误”。发生异常”。
当在Excel 2010上调用.open方法时,下面提到的过程test1使特定用户组的Excel崩溃,而其他用户组则能够成功执行该过程。同一用户在两周前能够执行此功能,突然有一天它开始引发错误。
下面提到的使用ADO 2.7、2.8和6.1库进行过程测试,但无济于事。
Sub test1()
Dim conn As New ADODB.Connection
Set conn = OpenConnection(ThisWorkbook.FullName)
MsgBox conn.State = adStateOpen
End Sub
Public Function OpenConnection(ByVal sDB_Path As String) As ADODB.Connection
Dim conn As New ADODB.Connection
conn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & sDB_Path & "; " & "Extended Properties=""Excel 12.0;HDR=YES;IMEX=1;"""
Set OpenConnection = conn
End Function