Hello, for the last few hours I’ve been trying to use Execute Macro activity and pass arguments but the macro doesn’t work as expected and I would appreciate some help.
What I want to achieve is to copy a specific row, insert the copied row just below it, and insert a value in a cell of the new row. I’ve created a macro that works fine when running it from excel or when using Execute Macro activity without passing any arguments. But when I pass in a few arguments, even though the arguments are passed in correctly (I can display them inside a message box in excel), the macro doesn’t copy the row and inserts the new value in whatever the current active cell is.
VBA code for the macro:
Sub Macro1(intInsertPosition As Integer, strColumnLetter As String, strInsertValue As String) Rows(intInsertPosition - 1).Select Selection.Copy Rows(intInsertPosition).Select Selection.Insert Shift:=xlDown Range(strColumnLetter + CStr(intInsertPosition)).Select Application.CutCopyMode = False ActiveCell.FormulaR1C1 = strInsertValue End Sub
And here’s a screenshot of the Execute Macro activity:
I have no idea what could be the issue. I have checked these two links to see how to pass arguments: link1 and link2, but since I can display the arguments in excel with a message box I think the passing of the arguments is fine. In these threads 2 other methods of running a macro were mentioned: using a VBScript file with a Start Process activity and using Invoke Code activity but I don’t know if it’s actually possible. If someone could provide an example that would be great.
I am also uploading the .xaml and excel files here: MacroWithArguments.zip (19.4 KB)
Thank you kindly!