views:

1241

answers:

1

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 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.

+1  A: 

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?

Tom Winter
I tried to do it in code that opens the document; but then it gets fired even before the document gets fully loaded.
gk
What's getting fired? What's not fully loaded? Opening a doc is not async. After your code opens it, it can do anything to it. What are not able to do, specifically?
Tom Winter