How to return value from a VBA Sub to Uipath

I’ve a Sub written in VBA and would like to return a value from Sub to UiPath’s invoke activity. How I can do this ?

Sub Test()
 On Error GoTo eh
  Range("A2").Select
  returnTxt = "OK"
Exit Sub
eh:
  returnTxt = Err.Description
End

Hello @suripaleru
Refer to this video, You may get some idea

HI @suripaleru

You need to create a variable in the output field in the invoke VBA and that variable will store the value if anything that is getting outputted

Regards
Sudharsan

@suripaleru

Use a function instead of sub to return the values

Cheers

Hi @suripaleru ,

Please find the attached files. It will helps you how to get the output from VBA(As well how to pass the arguments from UiPath to VBA).

Regards,
Pavan Kumar
New folder.zip (14.0 KB)

If any one needs a step by step guide on how to use functions and subs to get output value here is a video explaining the process step by step: