I am trying to use Office Automation in Delphi Tokyo to open a Word document (using Word 2016). The document has a Document_Open macro that prompts the user to optionally run another macro.
When I run the following code:-
Doc := IDispatch(WordApp.Documents.Open([*filename*])) as _Document;
the document opens, but the Document_Open macro does not run. Also, if I try to run the second (main) macro manually, I get an error saying "The macros in this project are disabled ..."
However, if I open the same document from the Word file menu, the macros run as expected, so they are clearly not disabled.
The VBA project is digitally signed and Word is set to "Disable all macros except digitally signed macros".
How do I get my macros to run when opening the document from within Delphi?