2

I am trying to pass values to an XL macro from within UiPath.

Within XL, I managed to pass values from a button to a macro.
This is how I called my macro from the button.

'macroTest("A12")'

I tried this without the single quotes but it did not work. And it did not work without the double quotes around the string.

I tried creating a variable within UiPath like this "'macroTest(" & CHR(34) & "A12" & CHR(34) & " )'"

But I got no luck.

Any ideas would be greatly appreciated.

Hugh Abbott
  • 23
  • 2
  • 8

2 Answers2

0

For now you cannot pass parameters to the macro with Execute Macro activity. What you can do is write the values in a separate sheet, in some fixed cells using Write Cell activities and have the macro read the values from there. Do you think this would help?

Also, you can try asking on our Community Forum: https://uipath.zendesk.com/hc/en-us/community/topics.

0

You can pass arguments to the parameters in a VBA macro from UiPath, but it must be done correctly.

  1. In the Excel Application Scope properties, MacroSettings must be enabled.
  2. The Invoke VBA activity must be inside the Excel Application Scope.
  3. The VBA code must be in a .txt file. This means you can run a macro on any type of workbook (i.e. .xlsx or .xls); not just .xlsm file types.
  4. The arguments passed must be in some type of collection. I used an array in this example.
  5. Your Macro Settings inside the Trust Center must be correct (see below).

enter image description here

enter image description here

enter image description here

enter image description here

Excel Settings

To make the proper settings selection, in your Excel workbook, navigate to File -> Options -> Trust Center -> Trust Center Settings… -> Macro Settings. Under Developer Macro Settings, ensure Trust access to the VBA project object model is selected.

enter image description here

Scott Ridings
  • 744
  • 1
  • 8
  • 14
  • Thank you so much @scott I'm sure loads of people have this problem ... your insight will be much appreciated ! – Hugh Abbott Jul 19 '23 at 13:51