Convert doc documents to Rich Text Format [C #]

Source: Internet
Author: User
The conversion first adds a reference to the Microsoft Word 9.0 Object Library in the project reference.

Using System;

Namespace Docconvert

{
Class Doctortf
{
static void Main ()
{

Create an instance of Word
Word.Application Newapp = new Word.Application ();

Specify source and destination files
Object Source= "C:\\abc\\source.doc";
Object target= "C:\\abc\\target.rtf";

Object Unknown =type.missing;

Open the Word file you want to convert
NewApp.Documents.Open (ref Source,ref Unknown,
Ref Unknown,ref Unknown,ref Unknown,
Ref Unknown,ref Unknown,ref Unknown,
Ref Unknown,ref Unknown,ref Unknown,
Ref Unknown);

Specify the type of document
Object format = Word.WdSaveFormat.wdFormatRTF;

Change Document Type
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);

Close Word Instance
Newapp.quit (ref unknown,ref unknown,ref Unknown);

}
}
}




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.