尝试创建ADODB.Connection对象时出现错误429

时间:2017-10-27 14:03:54

标签: excel excel-vba adodb vba

我创建了一个Excel Userform,它与Access DB连接以检索用户待处理任务并将其列为状态。这个excel文件由6名分析师运行,没有任何问题,但有一个已经收到运行时错误429:activeX组件无法创建对象。

获得错误的用户是唯一使用x86窗口的用户。

我已经尝试过XL参考不成功的所有版本的MS ActiveX Data Objects x.x库

我还尝试安装Access数据库引擎,错误仍然存​​在

遵循代码:

Public Const conStr As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data   Source=\\SAO229DT91264\Planej_dev\Planilhao.accdb;Persist Security   Info=False;"
Public CN As ADODB.Connection
Public RS As ADODB.Recordset
_______________________________________________________________
Function importDB(ByVal filter As String)
    Dim line As Long
    Dim col As Long
    Dim tim  As Date
    Dim user As String
    Dim query As String

    query = "Select Code, indice, flNO, dtStart, dtEnd, Pattern, orig, std, sta, dest, mkt, resp, order, motiv, status, action, obs, dtMsg, numMsg, dtVigencia, daysOps, dtAdd, dtChg from Alterations"

    tim = Now()
    user = CStr(Application.UserName)

    Set CN = New ADODB.Connection 'The code stops here With the runtime error
    Set RS = New ADODB.Recordset

    WS.Unprotect

    line = WS.Cells(Rows.Count, 1).End(xlUp).Row
    If linha > 2 Then WS.Range(WS.Cells(3, 1), WS.Cells(linha, 23)).ClearContents

    CN.Open conStr
    RS.Open query & " " & filter & " order by code asc;", CN

    line = 2

    Do While Not RS.EOF
        line = line + 1
        For col = 1 To RS.Fields.Count
            If col = 4 Or col = 5 Then
                WS.Cells(line, col).NumberFormat = "@"
                WS.Cells(line, col) = CStr(Format(RS.Fields(col - 1).Value, "dd/MMM/YYYY"))
            Else
                WS.Cells(line, col) = RS.Fields(col - 1).Value
            End If
        Next col
        RS.MoveNext
    Loop

    CN.Close
    WS.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
    , AllowSorting:=True, AllowFiltering:=True
    End Function

1 个答案:

答案 0 :(得分:0)

我首先删除工具中的adodb引用,故障机器上的引用,保存并关闭。重新打开并重置引用,然后重新编译。

相关问题