c# - Opening a Microsoft Word document in a Windows service seems to hang -
I have a Windows service that is written in C # which reads text from Word documents (Doctor and Doc) , Which use VBA interop. However, on some documents this call is hanging on the open method. It seems that they have macros in problem documents. Locally installed macro macros are disabled and the code I use to open the document is as follows:
Word = Microsoft Using Office.Interop.Word; Using OfficeCore = Microsoft.Office.Core; Word.Application m_wordApp = New Word.ApplicationClass (); Word.Document m_wordDoc = null; Object TRUE_VALUE = true; Object FALSE_VALUE = false; Object MISSING_VALUE = System.Reflection.Missing.Value; M_wordApp.DisplayAlerts = Microsoft.Office.Interop.Word.WdAlertLevel.wdAlertsNone; // will still fail with this line m_wordApp.Visible = false; // will still fail with this line m_wordApp.AutomationSecurity = Microsoft.Office.Core.MsoAutomationSecurity.msoAutomationSecurityForceDisable; // will still be removed from this line m_wordDoc = m_wordApp.Documents.Open (RIF filename, Riff FALSE_VALUE, Ref TRUE_VALUE, Ref FALSE_VALUE, Ref MISSING_VALUE, Ref MISSING_VALUE, Ref MISSING_VALUE, Ref MISSING_VALUE, Ref MISSING_VALUE, Ref MISSING_VALUE, Ref MISSING_VALUE , Riff FALSE_VALUE, Ref MISSING_VALUE, Ref MISSING_VALUE, Ref MISSING_VALUE, Ref MISSING_VALUE);
I can manually process these documents on my developing machine. Does anyone know why this is happening or there are more questions about my question?
Microsoft Office.Interop.Word
the actual word execute remotely Uses a COM wrapper to control. This is quite scary, the setting to disable the macro in the copy of Word is almost certainly a user-specific setting and the Windows service word will be running, which is under all the user accounts running under the service. It is likely that this is essentially popping up some types of macro security dialogs in some theoretical networld, which is a Windows service user desktop / UI.
Comments
Post a Comment