Execute Macro Activity Runs Twice

excel
activities
macro
p_known

#1

We are currently in the process of making our first production workflow and for a part we wanted to leverage existing VBA code to handle a process. I am utilizing the Execute Macro activity and my string is being passed successfully to the Excel file. However after running through the macro once it runs it again. There are no loops in my test workflow nor in my VBA code so I am perplexed. This seems like a bug with UiPath. I saw a few others post in threads with similar concerns and they received no answers. There was a possible other thread that may have held an answer but the thread was not in english.


Passing Argument to Excel Macro
#2

Not sure about this I’ve asked @beesheep to confirm if there’s an answer as my Spanish isn’t good enough… :slight_smile:

If not I’ll look into it further, do you have an example .xaml ? You could try running it passing a dummy parameter to see if that works (not a perfect solution admittedly).

https://forum.uipath.com/t/passing-argument-to-excel-macro/3868

RD


#3

So update on this issue. I contacted UiPath directly and received confirmation there is a known bug when calling a macro with parenthesis. Going a bit off memory here since I don’t have my work email in front of me but calling a macro like “MyMacro” should work fine. Calling it like “MyMacro()” or “MyMacro(param1, param2, param3, etc…)” will cause it to run twice. So if you need to pass parameters to it you’ll have to pass it from a file or some other means. I didn’t get around to testing this out yet but wanted to pass along the information.


#5

Posting a link to @badita’s response


#7

My macro is still running twice. Looks like this bug is not being addressed. I am using version 2018.2.3


#8

What s the excel pack version used?
Can i see the excel file and workflow?


#9

Excel 2013 (15.0.5041.1000) 32-bit

The workflow calls a Select file activity for the user to select a file.
Then the macro is called to simply output the full path of the file selected.
Somehow the two messages pop up twice.

Main.xaml (7.3 KB)

I can’t upload the .xlsm file. But here’s the very simple macro code:

Sub Test(s As String)

    MsgBox s
    MsgBox "This message should not appear again."

End Sub

#10

i don`t think you have the latest excel package installed, can you upgrade from Package manager?


#11

Just reinstalled Excel package. Still the same issue.


#12

you need to change your workflow and pass the arguments in Macro parameters property of the activity.


#13

‘String’ cannot be converted to ‘System.Collections.Generic.IEnumerable(Of Object)’ because ‘Char’ is not derived from ‘Object’, as required for the ‘Out’ generic parameter ‘T’ in ‘Interface IEnumerable(Of Out T)’.

How do you convert String to System.Collections.Generic.IEnumerable to be passed in Macro parameters?

Can you edit my workflow and upload the correct version?


#14

you need to have a list of string variables, as parameters


#15

Ah it works now. Thanks!


#16

It looks like the updated activity fixed my issue as well. Just ran a quick test passing and returning values from a macro and it ran without a duplicate run.