At a high level, I am building a format command, within VBA, like,
“ActiveDocument.Words(intWordPointerL).Font.Italic = True”
I then want to execute the command.
At first it seemed like “Eval” or “Application.Run” might be a solution, but I haven’t gotten them to work.
Seems like they are looking for existing function/sub references, rather than a free form string.
I’d like something like the PowerShell Invoke-Expression command.
To simplify, I’m working with the base command, preformed,
“ActiveDocument.Words(intWordPointerL).Font.”
Then appending one of a variety of qualifiers, like “Italic = True”.
Tried using “Eval”.
Tried using Application.Run.
Both seem to require a reference to and existing Macro.
If I can’t invoke the command directly, can I create a macro on the fly and then invoke it?
I found this answer to a similar question relative to Excel,
/questions/36595499/vba-execute-string-as-command-in-excel
(sorry, tried to post the code here, but kept getting error about formatting it properly)
If it works in Excel, it could probably be adapted to work in Word.
I’m not strong in VBA.
I don’t understand how to convert this Excel-centric code for MS-Word usage.