Run-time error '-2147467261 (80004003) Object reference not set to an instance of an object

拈花ヽ惹草 提交于 2020-01-25 10:37:09

问题


I'm getting the following error on the line 'ua' below. I'm trying to automate an Upsert to Salesforce through VBA using the enabler4excel object [automationObject].

Run-time error '-2147467261 (80004003)

Object reference not set to an instance of an object

Here is my code:

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:


I don't see where you dim ua but it is an object I assume (i.e. not an integer or string or boolean...) which means you need to use the keyword set

Set ua = automationObject.UpsertData(AccUpArray, ObjectName, ExternalId, False, Nothing, error)

Not seeing where you dim this could also mean you are not using Option Explicit. You should be.



来源:https://stackoverflow.com/questions/23683973/run-time-error-2147467261-80004003-object-reference-not-set-to-an-instance-o

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!