Convert DOC document into RTF format [C #] (reproduced)

zhaozj2021-02-16  197

I haven't updated the article on a CodeProject, and the original code has a problem, modify the compile. Originally adds a reference to Microsoft Word 9.0 Object Library first in the project reference.

Using system;

Namespace DocConvert

{Class DoctorTF {static void main () {

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

// Specify source file and target file Object Source = "c: //abc//source.doc"; object target = "c: //abcl//target.rtf";

Object UNKNOWN = Type.Missing;

// Open the file you want to convert Word 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 the 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);

// Turn off the Word instance newapp.quit (ref unknown, refnown);

}}}

转载请注明原文地址:https://www.9cbs.com/read-8280.html

New Post(0)