![]() |
Macro get executed twice
Hi,
I have an add-in which I load in Excel by passing the add-in to Excel command line. The add-in opens a workbook does some work and then invokes a macro present in the workbook as belows Application.Run ("'" & RptObj.Name & "'!" & strMacroName) I have observed that the Macro is invoked twice if the strMacroName has macro name like Main() i.e. with parantheses. But if strMacroName does not contain "()" parantheses then macro is invoked once only. Any idea what is happening or what I did wrong. Thanks for any help in advance. |
Macro get executed twice
Macro names never have () in them. Those parens are used to hold the parms that
could be passed to the routine. Don't include them in your strMacroName. Anand Nichkaode wrote: Hi, I have an add-in which I load in Excel by passing the add-in to Excel command line. The add-in opens a workbook does some work and then invokes a macro present in the workbook as belows Application.Run ("'" & RptObj.Name & "'!" & strMacroName) I have observed that the Macro is invoked twice if the strMacroName has macro name like Main() i.e. with parantheses. But if strMacroName does not contain "()" parantheses then macro is invoked once only. Any idea what is happening or what I did wrong. Thanks for any help in advance. -- Dave Peterson |
Macro get executed twice
Thanks for the information.
If strMacroName does not have the "()" then it is invoked only once. But we have a requirement where one can pass parameters to the macro in which case the Macro gets executed twice. Any information is appreciated. "Dave Peterson" wrote: Macro names never have () in them. Those parens are used to hold the parms that could be passed to the routine. Don't include them in your strMacroName. Anand Nichkaode wrote: Hi, I have an add-in which I load in Excel by passing the add-in to Excel command line. The add-in opens a workbook does some work and then invokes a macro present in the workbook as belows Application.Run ("'" & RptObj.Name & "'!" & strMacroName) I have observed that the Macro is invoked twice if the strMacroName has macro name like Main() i.e. with parantheses. But if strMacroName does not contain "()" parantheses then macro is invoked once only. Any idea what is happening or what I did wrong. Thanks for any help in advance. -- Dave Peterson |
Macro get executed twice
If you want to pass parms, change:
Application.Run "'" & RptObj.Name & "'!" & strMacroName to: Application.Run "'" & RptObj.Name & "'!" & strMacroName, "parm1", "Parm2" or if they're variables: Application.Run "'" & RptObj.Name & "'!" & strMacroName, varParm1, varParm2 But strMacroName still doesn't have ()'s in it. Anand Nichkaode wrote: Thanks for the information. If strMacroName does not have the "()" then it is invoked only once. But we have a requirement where one can pass parameters to the macro in which case the Macro gets executed twice. Any information is appreciated. "Dave Peterson" wrote: Macro names never have () in them. Those parens are used to hold the parms that could be passed to the routine. Don't include them in your strMacroName. Anand Nichkaode wrote: Hi, I have an add-in which I load in Excel by passing the add-in to Excel command line. The add-in opens a workbook does some work and then invokes a macro present in the workbook as belows Application.Run ("'" & RptObj.Name & "'!" & strMacroName) I have observed that the Macro is invoked twice if the strMacroName has macro name like Main() i.e. with parantheses. But if strMacroName does not contain "()" parantheses then macro is invoked once only. Any idea what is happening or what I did wrong. Thanks for any help in advance. -- Dave Peterson -- Dave Peterson |
All times are GMT +1. The time now is 05:40 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com