SIGN UP MEMBER LOGIN:    
ARTICLE

Convert Microsoft Office Word to other formats (pdf, html, rtf, xps)

Posted by Suthish Nair Articles | Office Development August 24, 2010
This article shows how to convert a Microsoft Word document to other document formats such PDFs, HTML, Rich Text Format (RTF), Text, XML, xps.
Reader Level:
Download Files:
 

This code snippet shows how to convert a Microsoft Office Word document to other document formats such 

PDFs, HTML, Rich Text Format (RTF), Text, XML, xps. We are going to use Office Interoperability for this purpose. 

Download the Primary Interop Assemblies (PIAs) from following links.

MS Office 2007

http://www.microsoft.com/downloads/en/details.aspx?FamilyID=59daebaa-bed4-4282-a28c-b864d8bfa513&displaylang=en

MS Office 2010

http://www.microsoft.com/downloads/en/details.aspx?FamilyID=938fe8ad-583b-4bd7-a345-23250dc15855

Adding the references.

  • Right click on your project.
  • Select Add Reference.
  • Go to .Net tab.
  • Select Microsoft.Office.Interop.Word from list.
    Samples attached using MS Office 2010 PIAs.
    1.jpg

    Sample codes attached. If you have any questions, post them below.

Login to add your contents and source code to this article
Article Extensions
Contents added by Suthish Nair on Mar 02, 2011
yes, referring from bin folder only. You need to add the dlls to bin folder. 
Contents added by Sunita Tajanpure on Dec 28, 2010
Does this reference to Microsoft.Office.Interop.Word or Excel refer to the GAC assembly or to the bin folder?

I want a code that should refer to the sin folder dlls not from the local system assemblies
Can anyone tell how to do this?


share this article :
post comment
 

Thanks for that. I already used it.But the Client side dont have any ms office suite installed. So i tried with "MS Office" viewer. I think its a freeware and just installed in client machine will help them to view/Print the document with one Constraint that it has to installed on all machine in the Client Side. Like that is there any other option that can be installed in Server and shared with the Client Machine that connect to that Server. Thanks,

Posted by vijay rags Mar 07, 2011

Hi,
I have a large number (2000+) of word files from my Mac (MS Word 2004 for Mac) that I have transferred to my XP machine. I wish to open them in a c# 2010 express application that I am developingg. I have Office 2010 installed on that machine also.

I have used your suggestions to open the files. If I open them first in Word 2010, then my application will open them fine. If I attempt to open them direct (after changing the extension to .doc), I get an InteropServices.COMException.
Any ideas?
Thanks,
Peter

Posted by Peter Sep 11, 2010
Team Foundation Server Hosting
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
    Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
Become a Sponsor