Hi
I have a windows service written in c# which reads the text from word documents (doc and docx) using VBA interop. However on certain documents it seems to hang on the call to the Open method. It seems that the problem documents all have macros in them. The locally installed version of word has macros disabled and the code I use to open the document is as follows:
using Word = Microsoft.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 removed
m_wordApp.Visible = false; //will still fail with this line removed
m_wordApp.AutomationSecurity = Microsoft.Office.Core.MsoAutomationSecurity.msoAutomationSecurityForceDisable; //will still fail with this line removed
m_wordDoc = m_wordApp.Documents.Open(ref fileNameObject, ref 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, ref FALSE_VALUE, ref MISSING_VALUE, ref MISSING_VALUE, ref MISSING_VALUE, ref MISSING_VALUE);
I can process these documents manually on my dev machine. Does anyone know why this is happening or have any further questions about my question?
Thanks
K