In principle you can create a macro at runtime through the properties and methods of the application's VBE object. In practice it's damned difficult --
1. Most security set-ups completely block any programmatic modification of the code environment (this is a major virus vulnerability).
2. Making changes to the VBA project resets the project -- that is, stops any running code and clears all variables.
If you already have an add-in, why can't you set up the macro and the toolbar in advance?
"ATS" <ATS[ at ]discussions.microsoft.com> wrote in message news:903DA605-FDB4-4A47-BE8A-0CF57863D7EE[ at ]microsoft.com...
[Quoted Text] > HOWTO create macro programmatically for command bar buttons. > > I want to programmatically create a macro that I then programmatically > make > a command bar button for to call via its OnAction. I know how to add the > command bar button dynamically and sets its OnAction, but I can not figure > out how to create a macro (or AddIn) programmatically such that the button > could then call it. > > What can one do?
|