in Visual Studio .net IDE
?
Add references: in COM tab, find out "Microsoft Word blahblah" component.
Example code:
OpenFileDialog openFile = new OpenFileDialog();
openFile.InitialDirectory = System.AppDomain.CurrentDomain.BaseDirectory;if(openFile.ShowDialog() == DialogResult.Cancel)
{
??? return;
}object fileName = (object)openFile.FileName;
Word.Application x = new Word.ApplicationClass();
Word.Document d = new Word.DocumentClass();Type wordType = x.GetType();
Type docType = d.GetType();object nothing = System.Reflection.Missing.Value;
d = x.Documents.OpenOld(ref fileName, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing);
string str = "";
foreach (Word.Range r in x.ActiveDocument.Words)
{
??? str = str + " " + r.Text;
}MessageBox.Show(str);
if (d != null)
{
??? d.Close(
??????? /* ref object SaveChanges */ ref nothing,
??????? /* ref object OriginalFormat */ ref nothing,
??????? /* ref object RouteDocument */ ref nothing);
??? d = null;
}if (x != null)
{
??? x.Quit(
??????? /* ref object SaveChanges */ ref nothing,
??????? /* ref object OriginalFormat */ ref nothing,
??????? /* ref object RouteDocument */ ref nothing);
??? x = null;
}
老大这也太简单的点吧。。。。
提容易了谁不会啊
有本事把Word的内容原样输出啊