Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel 运行时错误'-2147467261(80004003)对象引用未设置为对象实例_Excel_Vba_Salesforce - Fatal编程技术网

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

Excel 运行时错误'-2147467261(80004003)对象引用未设置为对象实例,excel,vba,salesforce,Excel,Vba,Salesforce,我在下面的“ua”行中得到以下错误。我正在尝试使用enabler4excel对象[automationObject]通过VBA自动插入Salesforce 运行时错误'-2147467261(80004003) 对象引用未设置为对象的实例 这是我的密码: Dim addin As Office.COMAddIn Dim automationObject As Object For Each addin In Application.COMAddIns If addin.Descript

我在下面的“ua”行中得到以下错误。我正在尝试使用enabler4excel对象[automationObject]通过VBA自动插入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

我看不出您在哪里设置
ua
,但我假设它是一个对象(即不是整数、字符串或布尔值…),这意味着您需要使用关键字
set

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

看不到暗显的位置这也可能意味着您没有使用
选项Explicit

黑暗会是什么样子?我没有使用Option Explicit,因为我无法弄清楚这一点。@Amphitrite没有使用Option Explicit是导致类似错误的原因。现在我在这一行上得到一个“需要对象”错误-有什么想法吗?:Dim result As Object Dim error Set result=automationObject.LogIn(用户名、密码,“,错误)如果结果=False,则MsgBox error End(如果看起来是几行)。您正在
Dim
ing
result
error
但您将
Dim
error
作为变量,稍后将其用作字符串。您应该将其设置为适当的数据类型。如果您将
结果声明为对象
,但测试它是否为
false
。除非从login方法返回的对象具有布尔类型的默认属性,否则您可能应该将
result声明为boolean