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 6179355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:38:51+00:00 2026-05-24T00:38:51+00:00

I am writing a C# Window service to be run on a Server (installed

  • 0

I am writing a C# Window service to be run on a Server (installed with OFFICE)
i need to convert MS Word DOC to RTF file and load it into RICHTEXTBOX, and get the RTF string and Plaintext String to DB (get the Plaintext string for full text indexing allowing user the search)

i used the following code the perform the conversion in the Service,
However, it error occurred on the line
newApp.Documents.Open
“There is insufficient memory. Save the document now”

i’ve check on the Server task manager and i found the Winword.exe is loading lot of memory (says 60~70 Mb) and it don’t quit (well, it get exception….. >_<)

i’ve try the same code run in the same machine with Windows Form, and it got no error.
and the service is set run as Administrator already.

    private void doc2rtf(object Source, object Target)
    {
        //Creating the instance of Word Application
        Word.Application newApp = new Word.Application();

        newApp.AutomationSecurity = Microsoft.Office.Core.MsoAutomationSecurity.msoAutomationSecurityForceDisable;
        newApp.DisplayAlerts = Word.WdAlertLevel.wdAlertsNone;

        // specifying the Source & Target file names

        // Use for the parameter whose type are not known or  
        // say Missing

        object Unknown = Type.Missing;
        object objReadOnly = true;
        object objFalse = false;
        try
        {
            // Source document open here

            // Additional Parameters are not known so that are  
            // set as a missing type
            lw.writeLog(LogWriter.logType.DEBUG, "before newApp.Documents.Open", Source.ToString());
            newApp.Documents.Open(ref Source, ref Unknown,
                 ref objReadOnly, ref Unknown, ref Unknown,
                 ref Unknown, ref Unknown, ref Unknown,
                 ref Unknown, ref Unknown, ref Unknown,
                 ref Unknown, ref Unknown, ref Unknown, ref Unknown);
            lw.writeLog(LogWriter.logType.DEBUG, "after newApp.Documents.Open", Source.ToString());
            // Specifying the format in which you want the output file 

            object format = Word.WdSaveFormat.wdFormatRTF;

            //check header footer exists.
            lw.writeLog(LogWriter.logType.DEBUG, "before newApp.ActiveDocument.SaveAs", Target.ToString());
            //Changing the format of the document
            newApp.ActiveDocument.SaveAs(ref Target, ref format,
                    ref Unknown, ref Unknown, ref Unknown,
                    ref Unknown, ref Unknown, ref Unknown,
                    ref Unknown, ref Unknown, ref Unknown,
                    ref Unknown, ref Unknown, ref Unknown,
                    ref Unknown, ref Unknown);
            lw.writeLog(LogWriter.logType.DEBUG, "after newApp.ActiveDocument.SaveAs", Target.ToString());
        }
        catch (Exception e)
        {
            lw.writeLog(LogWriter.logType.ERROR, e.Message, "doc2rtf");
        }
        finally
        {
            lw.writeLog(LogWriter.logType.DEBUG, "before newApp.ActiveDocument.Close(", "");
            newApp.ActiveDocument.Close(ref objFalse, ref Unknown, ref Unknown);
            // for closing the application
            lw.writeLog(LogWriter.logType.DEBUG, "after newApp.ActiveDocument.Close(", "");

            lw.writeLog(LogWriter.logType.DEBUG, "before newApp.ActiveDocument.Quit(", "");
            newApp.Quit(ref objFalse, ref Unknown, ref Unknown);
            lw.writeLog(LogWriter.logType.DEBUG, "after newApp.ActiveDocument.Quit(", "");
            newApp = null;

            GC.Collect();
        }
    }
  • 1 1 Answer
  • 0 Views
  • 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-24T00:38:53+00:00Added an answer on May 24, 2026 at 12:38 am

    If you’re using Windows Server 2008 (or possibly also Windows 7), then see my answer to this question. It might help.

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

Sidebar

Related Questions

I'm writing a Windows service and need to make authenticated web requests. The service
I'm writing a Windows Service that needs to take a file from an FTP
I am writing an application in C# that needs to run as a service
I'm writing a C# application to control the windows tomcat service. I need a
I'm writing an ASP.NET web application which will run on Windows Server 2008 (IIS7).
I'm writing a windows service that once started will run every X hours. The
I have a windows service act as a server. And I run one windows
I am writing a Windows service that pulls messages from an MSMQ and posts
I'm writing a windows service which will be used to monitor some other services
I am writing a windows service. This service runs another process I've developed through

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.