Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Office word interop

Status
Not open for further replies.

pdbowling

Programmer
Mar 28, 2003
267
US
Hello, All.

In word you can SaveAs and at the bottom of the dialog box you can choose different formats. I'd like to save as a plain text file but using C Sharp code. Below is the code I have that is opening the file, but that save as a plain text syntax is eluding me.

I'm using Visual Studio 2008 and the Microsoft.Office.Interop.Word 12 assembly.
Code:
Microsoft.Office.Interop.Word.ApplicationClass word = new Microsoft.Office.Interop.Word.ApplicationClass();

Microsoft.Office.Interop.Word.Document doc = new 
Microsoft.Office.Interop.Word.Document();

object nullobj = System.Reflection.Missing.Value;

object fileNme = fileName;//fileName passed to function

doc = word.Documents.Open(ref fileNme, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj);

word.Visible = false;

Is anyone clear on the syntax for doing this?
Thanks, everyone.
P

Patrick is a distributor of Republic Magazine ( -free pdf copy downloadable ) and the webmaster of
 
if you want to create a plain text document you don't need MS Word.

use the objects in the System.IO namespace. there are a variety of ways to create text files.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
If I understand the OP correctly, he wants to open an existing .doc file and convert it to plain text. Are there ways of using the System.IO namespace to get the contents of a .doc file as the source stream?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top