Excel 运行时错误'-2147467261(80004003)对象引用未设置为对象实例
我在下面的“ua”行中得到以下错误。我正在尝试使用enabler4excel对象[automationObject]通过VBA自动插入Salesforce 运行时错误'-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
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
ingresult
和error
但您将Dim
error
作为变量,稍后将其用作字符串。您应该将其设置为适当的数据类型。如果您将结果声明为对象
,但测试它是否为false
。除非从login方法返回的对象具有布尔类型的默认属性,否则您可能应该将result声明为boolean