# Run Excel Macro

Hello.

I know Run Excel Macro action is currently unavailable but I’d like to enquire if there is a plan to add such functionality and if so when we could expect it to happen.

In the meanwhile can you perhaps provide a groovy script to run a macro? That would be very helpful. I know I can run macro with a mouse click or keystrokes, but I’d prefer to avoid it if possible.

Best,
Piotr

Hi Piotr,

There are no plans to add this feature in the nearest future. We might consider adding it further along the road depending on demand for it.
You can vote for this feature using the button above to raise its priority.

Currently, you can create a vbs script to run a macro, and execute this script in a custom action.

The vbs script will be something like this (opens excel file and runs macro without saving it):

Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("path to excel file")
objExcel.Application.Visible = True
objExcel.Application.Run "'workbook'!macro"
WScript.Quit


The groovy script to run a vbs script is:

@CustomScriptAction(
)

def customScript() {
Process runtime = Runtime.getRuntime().exec('cmd /c start ' + 'path\\to\\vbs\\script');
}


I hope it helps!

1 Like

Thank you a lot!

I hope this will work. I’ll try to test it in coming days.

I have another question for a script. I’ll create another topic soon. Perhaps it would be a good idea if you had a library of custom scripts, or a subforum where everyone can post custom scripts.