Return error from Macro VBA

I write VBA macro and handle the error happening in macro but I want to get the error as output to UiPath
I try many methods using variables and and output UiPath method but it’s return as null

Sub ttt()
Dim x As Integer

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

Done:
Exit Sub
abc:
'Dim errMsg As String
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

End Sub

this example for error and handling but how get error msg to UiPath

Hi,

Can you try Function instead of Sub? The following sample may help you.

image

Sample
Sample20240507-1.zip (15.8 KB)

Regards,

Thank You it’s working fine with Fun
but why not work with a sub is there any reason or solution for it