0

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.

Malachi
  • 3,205
  • 4
  • 29
  • 46
gk.
  • 1,252
  • 3
  • 14
  • 23

2 Answers2

1

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
  • 1,813
  • 3
  • 18
  • 23
  • I tried to do it in code that opens the document; but then it gets fired even before the document gets fully loaded. – gk. Aug 10 '09 at 08:29
  • 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 Aug 11 '09 at 12:26
0

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.

Malachi
  • 3,205
  • 4
  • 29
  • 46