Convert the Doc file to the rtf Format

Source: Internet
Author: User
There is no update in a week.
If there is a problem with the original code of the article on a CodeProject, it is modified and compiled.
The original Article is here

First, add a reference to the Microsoft Word 9.0 object library in the project reference.
Code:

Using System;

Namespace DocConvert

{
Class DoctoRtf
{
Static void Main ()
{

// Create a word instance
Word. Application newApp = new Word. Application ();

// Specify the source and target files
Object Source = "c: \ abc \ Source.doc ";
Object Target = "c: \ abc \ Target. rtf ";

Object Unknown = Type. Missing;

// Open the Word file to be converted
NewApp. Documents. Open (ref Source, ref Unknown,
Ref Unknown,
Ref Unknown,
Ref Unknown,
Ref Unknown );

// Specify the Document Type
Object format = Word. WdSaveFormat. wdFormatRTF;

// Change the Document Type
NewApp. ActiveDocument. SaveAs (ref Target, ref format,
Ref Unknown,
Ref Unknown,
Ref Unknown, ref Unknown, ref Unknown );

// Close the 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.