运行时错误'-2147467261(80004003)对象引用未设置为对象的实例

时间:2014-05-15 16:32:59

标签: excel vba salesforce

我在下面的'ua'行收到以下错误。我正在尝试使用enabler4excel对象[automationObject]通过VBA自动将Upsert转换为Salesforce。

运行时错误'-2147467261(80004003)

对象引用未设置为对象的实例

这是我的代码:

Dim addin As Office.COMAddIn
Dim automationObject As Object

For Each addin In Application.COMAddIns
    If addin.Description = "Enabler for Excel" Then
        Set automationObject = addin.Object
    End If
Next addin

Dim error
result = automationObject.LogIn(Username,Password,"https://test.salesforce.com", error)
If result = False Then
      MsgBox error
      End
End If

Range("b1").Select
Selection.End(xlDown).Select
bot_acc = ActiveCell.Row

Dim ExternalId As String
ExternalId = Range("A1")

Dim ObjectName As String
ObjectName = "Account"

Dim AccUpArray(13, 9999) As Variant

For Column = 0 To 12
    For Row = 0 To bot_acc - 2
        AccUpArray(Column, Row) = Worksheets("Account").Range("A2").Offset(Row, Column)
    Next Row
Next Column

ua = automationObject.UpsertData(AccUpArray, ObjectName, ExternalId, False, Nothing, error)
If Not error = Empty Then
     MsgBox error
     End
End If

1 个答案:

答案 0 :(得分:0)

我不知道你在哪里调暗ua但它是我假设的一个对象(即不是整数或字符串或布尔...),这意味着你需要使用关键字{{1} }

set

没有看到你昏暗的地方也可能意味着你没有使用Set ua = automationObject.UpsertData(AccUpArray, ObjectName, ExternalId, False, Nothing, error) You should be