Opelt2

I used the code below and the AutoOpen macro in the word document does not run as expected. However, a "The macros in this project are disabled" message appears. I plan to use the code in an unattended process (after replacing the FileDialog code), so all dialogs must be suppressed. Any ideas why the message shows

Dim appWord As Microsoft.Office.Interop.Word.Application = New Microsoft.Office.Interop.Word.Application

Dim secAutomation As MsoAutomationSecurity

secAutomation = appWord.AutomationSecurity

appWord.Application.AutomationSecurity = Microsoft.Office.Core.MsoAutomationSecurity.msoAutomationSecurityForceDisable

appWord.DisplayAlerts = WdAlertLevel.wdAlertsNone

With appWord.FileDialog(MsoFileDialogType.msoFileDialogOpen)

.Show()

.Execute()

End With

appWord.AutomationSecurity = secAutomation



Re: Visual Studio Tools for Office MS Word: msoAutomationSecurityForceDisable generates "The macros in this project are disabled" message

Cindy Meister

Please note that general interop questions are off-topic in this forum. Please consult the "Please Read First" message at the top of the forum for a list of places to discuss such issues.

Office applications are not designed to run unattended; Microsoft does not support such a scenario. See

Considerations for server-side Automation of Office

http://support.microsoft.com/kb/257757/en-us

The message you're seeing is linked to the user's security settings. This dialog box cannot be suppressed if the user has this particular security setting ativated. There is - logically enough - no object model interface that will allow you to change a user's security settings. Closest you can get is this

How To Dismiss a Dialog Box Displayed by an Office Application with Visual Basic

http://support.microsoft.com/kb/307292






Re: Visual Studio Tools for Office MS Word: msoAutomationSecurityForceDisable generates "The macros in this project are disabled" message

Opelt2

Thank you for the reply. I will look at the products listed in the kb.

Basically, I just need to process word/excel documents that are base64 encoded as part of an XML file. Any macros in the documents must be disabled prior to processing. The goal is to automatically convert the document to TIFF files. Text and PDF documents can also be present in the XML file. At present the approach is to use the Informatik Image Driver to convert the documents as they are 'printed'. If you know of a simple way to do this, please let me know.

Thanks again.





Re: Visual Studio Tools for Office MS Word: msoAutomationSecurityForceDisable generates "The macros in this project are disabled" message

Cindy Meister

Opelt2 wrote:

Thank you for the reply. I will look at the products listed in the kb.

Basically, I just need to process word/excel documents that are base64 encoded as part of an XML file. Any macros in the documents must be disabled prior to processing. The goal is to automatically convert the document to TIFF files. Text and PDF documents can also be present in the XML file. At present the approach is to use the Informatik Image Driver to convert the documents as they are 'printed'. If you know of a simple way to do this, please let me know.

Well, if you could be sure the documents were all saved in the Word 2003 or Word 2007 XML file format, you'd be home free because you could just transform that directly. If that's not the case...

...besides the KB articles in my first message, there's only one other approach I know. That's to use the application.WordBasic.DisableAutoMacros method. If you're using VB.NET with Option Strict Off, that's the simplest way. Anything else, and you have to use late-binding (PInvoke).