运行时错误'-2147467261(80004003)对象引用未设置为对象的实例 [英] Run-time error '-2147467261 (80004003) Object reference not set to an instance of an object

查看:2370
本文介绍了运行时错误'-2147467261(80004003)对象引用未设置为对象的实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在下面的'ua'线上收到以下错误。我试图通过使用enabler4excel对象[automationObject]通过VBA自动化Upsert到Salesforce。

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].

运行时错误'-2147467261(80004003)

Run-time error '-2147467261 (80004003)

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

Object reference not set to an instance of an object

这是我的代码:

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


推荐答案

我没有看到你在哪里变暗 ua 但它是一个我假设的对象不是整数或字符串或布尔值...),这意味着您需要使用关键字 set

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)

没有看到你暗淡的地方也可能意味着你没有使用 Option Explicit 您应该是

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

这篇关于运行时错误'-2147467261(80004003)对象引用未设置为对象的实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆