Convert word document to text using c# running

I have a web application built using c#,  I need to convert an uploaded word document to a text string.  I have looked at (which works locally), but when I run on a server (where word is not installed) it doesn't work because the DLL is not registered.  It there another method of accomplishing this task?  OpenXML?

Here is code I have worked with thus far:

        public string convertWordToText(string fileName)
                object missing = Type.Missing;
                object readOnly = true;

                Microsoft.Office.Interop.Word.Application application = new Microsoft.Office.Interop.Word.Application();
                Microsoft.Office.Interop.Word.Document document = application.Documents.Open(fileName, ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);

                string text = document.Content.Text;
                ((Microsoft.Office.Interop.Word._Application)application).Quit(); //cast as _Application because there's ambiguity
                object saveChanges = Microsoft.Office.Interop.Word.WdSaveOptions.wdDoNotSaveChanges;
                ((Microsoft.Office.Interop.Word._Application)application).Quit(ref saveChanges, ref missing, ref missing); //cast as _Application because there's ambiguity
                return text;
            catch (Exception ex)
                Log.error("Error converting document to text.");
                return string.Format("An error occured when converting this document to text.  The error returned is '{0}'.  \n\nYou can try copy and paste instead.", ex.Message);
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Definitely want to use OpenXML. Using on the server is unsupported and may violate your licensing. Microsoft recommends using OpenXML via System.IO.Package.IO. See for more details, specifically the section entitled "Alternatives to server-side Automation"
please downlaod

office runtime from following location and install it on your server.
More on OpenXML, looks like Microsoft has an SDK for OpenXML built on top of System.IO.Packaging at (There are a few different versions and samples)

Then you should be able to us

using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;
// Open a WordprocessingDocument for editing using the filepath.
WordprocessingDocument wordprocessingDocument = 
    WordprocessingDocument.Open(filepath, true);
// Assign a reference to the existing document body.
Body body = wordprocessingDocument.MainDocumentPart.Document.Body;

Open in new window

Code taken from

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Éric MoreauSenior .Net ConsultantCommented:
There are also some 3rd party that can help you. The one I have used is
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Word

From novice to tech pro — start learning today.