gk.
gk.

Reputation: 1262

How to disable macros in office word 2003?

I am trying to convert a word report to PDF using Adobe distiller. Some of these word files have macros in them which shows a popup when the doc is opened and this stops the automation process.

We tried disabling the macros by

wordApplication.AutomationSecurity = Microsoft.Office.Core.MsoAutomationSecurity.msoAutomationSecurityForceDisable;

but now the application is not firing the Document Open event anymore, where the conversion code is implemented. The code is written, in the event, in order to make sure the conversion happens only after word loads the file.

Is there any other way to disable macros? Or any other approach so that I can disable the macros and also make sure the file is loaded in order to start the conversion process.

Upvotes: 0

Views: 3651

Answers (2)

Malachi
Malachi

Reputation: 3231

if I understand the question correctly, you could do a try ...catch...finally statement.

you just put the open code in the try, and set a variable to true if the file is opened, and then put an if/then statement in the Finally Statement so that if the document was opened it would run the conversion, and if the document wasn't opened you could return a message that the document was not converted and give a reason why. you would probably still have to disable the macros in the Case of the OP.

I know this is a very old post, but it might give others some ideas if they come across this post looking for help.

Upvotes: 0

Tom Winter
Tom Winter

Reputation: 1923

If you're disabling macros, then no code in the documents you open will run, including the code in the Document Open event. That's a "macro" after all. There's no way to have some of the macros in a single document run but not others.

Why are you having the conversion process happen in the document open event? Why not just do it in the code that opens the document?

Upvotes: 1

Related Questions