C#中如何利用word对象进行打印?? 我以前一直用VB,最近在学C#。在VB中可以利用word对象进行合同的打印。不只在C#中该如何处理打印问题?我看C#中也可以引用word对象,但不知该如何实现调用word对象进行打印?我是新手,有些东西还不是很明白,如果有问错的地方,大家别见笑!希望可以得到你们的帮助指点!多谢了!!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这是一个打开Word的方法,打印的话,Word.Document对象有PrintOut()方法,基本把VB的代码改改就能用using Word; Word.Application wdApp = null; static object missing = Missing.Value; private Word.Document OpenFile(string filePath) { Word.Document wdDoc = null; object fileName = filePath; object confirmConversions = missing; object readOnly = true; object addToRecentFiles = missing; object passwordDocument = missing; object passwordTemplate = missing; object revert = missing; object writePasswordDocument = missing; object writePasswordTemplate = missing; object format = missing; object encoding = missing; object visible = false; object openAndRepair = missing; object documentDirection = missing; object noEncodingDialog = missing; wdDoc = wdApp.Documents.Open( ref fileName , ref confirmConversions , ref readOnly , ref addToRecentFiles , ref passwordDocument , ref passwordTemplate , ref revert , ref writePasswordDocument , ref writePasswordTemplate , ref format , ref encoding , ref visible , ref openAndRepair , ref documentDirection , ref noEncodingDialog ); wdDoc.Activate(); return wdDoc; } Word.Application wordApplication = new Word.Application(); Word.Document thisDocument = new Word.Document(); object missingValue = Type.Missing; object myTrue = true; object fileName = "\\TestFile1.rtf"; wordApplication.Visible = true; thisDocument = wordApplication.Documents.Open(ref fileName, ref missingValue, ref myTrue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue, ref missingValue);Object background = Type.Missing;Object append = Type.Missing;Object range = Type.Missing;Object outputFileName = Type.Missing;Object from = Type.Missing;Object to = Type.Missing;Object item = Type.Missing;Object copies = Type.Missing;Object pages = Type.Missing;Object pageType = Type.Missing;Object printToFile = Type.Missing;Object collate = Type.Missing;Object fileName = Type.Missing;Object activePrinterMacGX = Type.Missing;Object manualDuplexPrint = Type.Missing;Object printZoomColumn = Type.Missing;Object printZoomRow = Type.Missing;Object printZoomPaperWidth = Type.Missing;Object printZoomPaperHeight = Type.Missing;ThisDocument.PrintOut(ref background, ref append, ref range, ref outputFileName, ref from, ref to, ref item, ref copies, ref pages, ref pageType, ref printToFile, ref collate, ref fileName, ref activePrinterMacGX, ref manualDuplexPrint, ref printZoomColumn, ref printZoomRow, ref printZoomPaperWidth, ref printZoomPaperHeight); 关于regsvr32的错误,急急急急急!!!! C#中类型转换的困惑!(首次发贴,大家多帮忙啊!) ADO.NET DataAdapter.Fill(DataTable)问题 问一个WinForm问题 js判断图片地址是否有图片 怎樣把datatable中的数据导出到excel 字符串的简单问题?(在线等) listbox的问题! 高分求救,如何将Form上的图片拖放到photoshop中 c#中的联系问题 c#会使用正则表达式的近来 C#里的哪个类可以获得指定URL的HTML?
基本把VB的代码改改就能用using Word; Word.Application wdApp = null;
static object missing = Missing.Value; private Word.Document OpenFile(string filePath)
{ Word.Document wdDoc = null; object fileName = filePath;
object confirmConversions = missing;
object readOnly = true;
object addToRecentFiles = missing;
object passwordDocument = missing;
object passwordTemplate = missing;
object revert = missing;
object writePasswordDocument = missing;
object writePasswordTemplate = missing;
object format = missing;
object encoding = missing;
object visible = false;
object openAndRepair = missing;
object documentDirection = missing;
object noEncodingDialog = missing; wdDoc = wdApp.Documents.Open(
ref fileName ,
ref confirmConversions ,
ref readOnly ,
ref addToRecentFiles ,
ref passwordDocument ,
ref passwordTemplate ,
ref revert ,
ref writePasswordDocument ,
ref writePasswordTemplate ,
ref format ,
ref encoding ,
ref visible ,
ref openAndRepair ,
ref documentDirection ,
ref noEncodingDialog ); wdDoc.Activate();
return wdDoc;
}
Word.Document thisDocument = new Word.Document();
object missingValue = Type.Missing;
object myTrue = true;
object fileName = "\\TestFile1.rtf";
wordApplication.Visible = true; thisDocument = wordApplication.Documents.Open(ref fileName, ref missingValue,
ref myTrue, ref missingValue, ref missingValue, ref missingValue,
ref missingValue, ref missingValue, ref missingValue,
ref missingValue, ref missingValue, ref missingValue,
ref missingValue, ref missingValue, ref missingValue);
Object background = Type.Missing;
Object append = Type.Missing;
Object range = Type.Missing;
Object outputFileName = Type.Missing;
Object from = Type.Missing;
Object to = Type.Missing;
Object item = Type.Missing;
Object copies = Type.Missing;
Object pages = Type.Missing;
Object pageType = Type.Missing;
Object printToFile = Type.Missing;
Object collate = Type.Missing;
Object fileName = Type.Missing;
Object activePrinterMacGX = Type.Missing;
Object manualDuplexPrint = Type.Missing;
Object printZoomColumn = Type.Missing;
Object printZoomRow = Type.Missing;
Object printZoomPaperWidth = Type.Missing;
Object printZoomPaperHeight = Type.Missing;ThisDocument.PrintOut(ref background, ref append,
ref range, ref outputFileName, ref from, ref to,
ref item, ref copies, ref pages, ref pageType,
ref printToFile, ref collate, ref fileName, ref activePrinterMacGX,
ref manualDuplexPrint, ref printZoomColumn, ref printZoomRow,
ref printZoomPaperWidth, ref printZoomPaperHeight);