简体   繁体   English

如何禁用Office Word 2003中的宏?

[英]How to disable macros in office word 2003?

I am trying to convert a word report to PDF using Adobe distiller. 我正在尝试使用Adobe distiller将单词报告转换为PDF。 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; 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. 但现在应用程序不再触发实现转换代码的Document Open事件。 The code is written, in the event, in order to make sure the conversion happens only after word loads the file. 为了确保仅在word加载文件后进行转换,编写代码。

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. 或任何其他方法,以便我可以禁用宏,并确保已加载文件以启动转换过程。

If you're disabling macros, then no code in the documents you open will run, including the code in the Document Open event. 如果禁用宏,则打开的文档中将不会运行任何代码,包括Document Open事件中的代码。 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? 为什么不只是在打开文档的代码中这样做呢?

if I understand the question correctly, you could do a try ...catch...finally statement. 如果我正确理解了这个问题,则可以try ...catch...finally语句。

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. 您只需将打开的代码放在try中,如果文件已打开,则将变量设置为trueif/thenFinally Statement中放置if/then语句,这样,如果打开了文档,它将运行转换,并且如果未打开文档,您可能会返回一条消息,指出文档未转换,并说明原因。 you would probably still have to disable the macros in the Case of the OP. 在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. 我知道这是一篇很老的文章,但是如果其他人遇到这个文章寻求帮助,它可能会给其他人一些想法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM