Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1067795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:12:16+00:00 2026-05-16T20:12:16+00:00

I have a windows service written in c# which reads the text from word

  • 0

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 developing machine. Does anyone know why this is happening or have any further questions about my question?

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T20:12:16+00:00Added an answer on May 16, 2026 at 8:12 pm

    I’ve hopefully finally found all the issues relating to this and have ended up with the following line to open the doc:

    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 TRUE_VALUE, ref MISSING_VALUE, ref TRUE_VALUE, ref MISSING_VALUE);
    

    The 4th and 2nd last parameters prevent repair and encoding dialogs from opening which fixed most of the errors.

    The registry key to turn disable macros without notification is:

    [HKEY_USERS\S-x-x-xx-xxxxxxxxxx-xxxxxxxxx-xxxxxxxxxx-xxx\Software\Microsoft\Office\12.0\Word\Security]
    "VBAWarnings"=dword:00000004
    

    Finally, after all that there were still docs that were crashing the service and leaking winword instances. After logging in as the service user and opening one of these documents I got this message dialog from word: “Word cannot start the converter mswrd632”. This is fixed by removing a registry key as explained in http://support.microsoft.com/kb/973904.

    Edit: I also found that because VBA was not installed Word opened a dialog to tell the service this which caused some of the documents to hang the service. Reinstalling it then disabling though Word itself (as explained above) got a few more documents processing. Still a few documents that can’t be processed. Thinking of trying http://poi.apache.org/text-extraction.html with ikvmc to parse the documents instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a windows service written in .net 4 which doing jobs periodically using
I have written a Windows Service which listens for data from a third party
I have written a Windows service to collect information from all of our SQL
I have a windows service executable that I know is written in .NET which
I have a very simple VB.net Windows Service written using VS.net 2008. The program
I have written a Windows service which should turn the display OFF when certain
I have a Windows Service written in .NET C# which calls a COM component.
I have a windows service written in c#. It has a timer inside, which
I have a application written in C#, installed as a [WCF] windows service, which
I have a windows Service written in C# 4.0 which uses Microsoft Exchange WebServices(EWS)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.