cancel
Showing results for 
Search instead for 
Did you mean: 

Uisng the Run Macro action in the Excel VBO to run a macro on a different worksheet in another workbook

PhilElliott
Level 3
Morning, I've seen a couple of other similar posts but nothing that asks this question specifically. How do I run a macro via BP on a worksheet in a workbook that doesn't contain the macro. If I was using Excel and from within Workbook X, Worksheet Y hit Alt F8 and brought up the macro dialogue I could select to view macros in all open workbooks. I could then select a macro that resided in Workbook A and run it but the code would be executed upon the worksheet from where I brought up the dialogue, Worksheet X in Workbook Y. There's a post further down that talks about adding extra code to the Run Macro action, some parameters are added. I've done that and the code validates, so I have something like this. See attached file, Untitled.jpg So my question is; is this correct, you will see that despite adding the extra parameters they are not displayed when I add the object via an action. Am I doing this correctly or completely incorrectly. Cheers, Phil.
2 REPLIES 2

Denis__Dennehy
Level 15
I have never tried what ask, but there is a Run Macro action in the MS Excel VBO. For a macro held in a different open workbook can you not put the full reference to the other workbook in. So rather than just passing the macro name as the input parameter try something like 'My Document.doc'!ThisModule.ThisProcedure If that does not work then you will need to create your own action that does what you need like previous posts suggest. The starting point for me would be googling the excel run command for more details.

MarkusKrahn
Level 3
Hey Phil, We faced a similar issue concerning private procedures and i can at least confirm, that calls like 'private procedure on specified sheet Instance.Run(Instance.Sheets(wks_name).CodeName+"".""+MacroName) 'procedure on specified workbook Instance.Run(""'""+WorkbookName+""'!""+MacroName) do work, so in theory, the suggested way by Denis should work out as well :) What I ended up doing was creating (admittedly messy) try nests, that listen for any COMException, to sort of preserve the simplicity of just calling one Action with a given procedure Name without having to worry about the actual implementation in the workbook much. Hope it helps! BR MaKrale