How to pass file path variable value in invoke VBA

Dear Friends,

I need to convert excel to .binary and i have decided to use invoke vba activity for that.
The following is my code:

Sub saveExcel(XlsbFilePath)

MsgBox (XslbFilePath)
ActiveWorkbook.SaveAs XslbFilePath, FileFormat:=50
Application.DisplayAlerts = False

End Sub

And this is how i use the invoke vba:

image

Variable “XslbFilePath” is actually of string type which contains filepath where to save the file.
But it failed when runs, and I think the problem is, because my Entry method parameters not right.
Error message is:

image

Can you please tell me what is wrong?
Thank you for your help.

Hi @Nazarius,

In your VBA code, the parameter you are passing to the subroutine is “XlsbFilePath”, but you are using another variable named “XslbFilePath” to pass it’s value to ‘SaveAs’ method and msgbox. Please try using same variable name in your entire VBA program, which doesn’t care about the one you used as parameter in UiPath.
Another reason for your issue may be with the filepath string you are passing. Use a write line activity to display the value of “XlsbFilePath” just before invoking VBA to make sure that you are using the correct File path with a proper format.

There is no issues with you EntryMethodParameter. You can also pass the argument along with method name like "'saveExcel("""+XlsbFilePath+""")'" :slightly_smiling_face:

Warm regards,
Nimin

1 Like

Dear @nimin ,

OMG!!! Stupid mistake and you spotted it right away. Thank you bro, I changed it and it worked perfectly.
Please people, do not stop helping each other. xD

Kr,

Naza

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.