How do I dynamically change the contents of a macro?
Use the Load Text command. This allows your macro to load in a text file at any point during the macro and execute the text as part of the macro. Your dynamic portion of the macro will be stored in the text file.
Any time you want to programmatically change the macro, change the text file that is inserted into the macro.