How to call a macro VBA with parameters from UiPath activity?

excel
macro

#1

exemplo:


Run VBS file from UiPath
How to execute Macro with arguments
#2

did you try invoke code activity .?


vbスクリプトをUIPATHで記述:I'd like to write a vb script in UIPATH
#3

I’m not familiar with sending an .xlsm file arguments to use with your macro, but I’d be interested to know if you can.

However, if your VBA is a .vbscript instead then you can use arguments with the Start Process. That requires a little knowledge on how to set up your script, though. The syntax isn’t that much different, but just need to open objects for your Excel file, etc.


#4

I decided to look it up and your syntax for VBA appears to be right.
However, you don’t have it as a string.
You might show what your error is.
“import(”“parameter”")"
If it just needs to be a string then something like that might work.


#5

ThankU ClaytonM it works. Now a tried with two parameters but do not work.

“Call export(”“validation”","“validation2"”)"
“Call export(”“validation,validation2"”)"
“export ““validation””,”“validation2"”"
"export ““validation, validation2"””

suggestions ?


#6

Hi, assuming macro name is “export”, I think it should be:
“export(”“validation”","“validation2"”)"

Try that one.


#7

Sorry, you’re right. I change the method name.

now is “export” kk


#8

O tried.


#9

Hmmm. “The range does not exist” makes it sound like there’s a problem inside the macro.
Other than that I’m unsure how to resolve it.

If it’s a problem with the macro, you could open the .xlsm file and create a Button that uses… Call export(“validation”,“validation2”) … so you can see if it runs without errors.


#10

I did it and runs okay. :disappointed:


#11

I didn’t try. How can I use invoke code ? Could you help me ? :pray:


#12

as of now its available in only community edition.are you using community or studio?


#13

studio :frowning:


#14

hang tight :upside_down_face: coming soon…


#15

Perfect !!!


#16

Hi ClaytonM, I tried your solution by including double quotes inside macro parentheses. It is working, but the macro is getting called twice in single “Execute Macro” activity.


#17

help pls,
not it work, i want pass a parameter to macro VBA, name macro is change_sheet(str As String).
sheet parameter type String.

thx :smiley: