我正在尝试从函数 Find123 返回一个对象。我已从子过程 Retrieve123 中调用它。
当我完成时,它说函数未定义,并突出显示 CObj 方法。
你能告诉我一种将整数或字符串转换为对象并在VBA中返回它的方法吗?
Sub Retrieve123()
Call Find123()
End Sub
Function Find123()As Object
Dim val As String
val="100"
Dim obj As Object
Set obj=CObj(val)
Set Find123 = obj
End Function
我需要将字符串转换为对象,因为在 UiPath 中我们只能返回对象类型,因为调用 VBA 活动的输出是对象类型。
我用它来处理错误
子ttt() Dim x 作为整数
On Error GoTo abc
x = "ss" ' This line will raise an error
For x = 1 To 10
Cells(x, 1).Value = 100
Next x
Exit Sub ' Go to Done if no error
完成: 退出子程序 ABC: '将 errMsg 调暗为字符串 errMsg = Err.Number & " " & Err.Source & " " & Err.Description
' Print the error message to the Immediate Window
Debug.Print errMsg
' Return the error description back to UiPath
ll = errMsg
Exit Sub
结束子
但是由于输出返回空值,如何将错误值检索到 uipath?