前提添加引用Microsoft.Office.Interop.Word; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using Microsoft.Office.Interop.Word; using System.IO; using System.Reflection; using oWord = Microsoft.Office.Interop.Word; using System.Drawing.Imaging; using System.Runtime.Serialization.Formatters.Binary; namespace ThreadStudy ... { class WordToTif ...{ /**//// <summary> /// 打印Word文档 /// </summary> /// <param name="wordfile">完整本地路径,包括文件名</param> /// <param name="outputFile">输出Tif文件的完整路径</param> public static void PrintWord(string wordfile, string outputFile) ...{ oWord.ApplicationClass word = new oWord.ApplicationClass(); Type wordType = word.GetType(); //打开WORD文档 oWord.Documents docs = word.Documents; Type docsType = docs.GetType(); object objDocName = wordfile; oWord.Document doc = (oWord.Document)docsType.InvokeMember("Open", System.Reflection.BindingFlags.InvokeMethod, null, docs, new Object[] ...{ objDocName, true, true }); //Word. //打印输出到指定文件 //可以使用 doc.PrintOut();方法,次方法调用中的参数设置较繁琐,建议使用 Type.InvokeMember 来调用时可以不用将PrintOut的参数设置全,只设置4个主要参数 Type docType = doc.GetType(); object printFileName = outputFile; docType.InvokeMember("PrintOut", System.Reflection.BindingFlags.InvokeMethod, null, doc, new object[] ...{ false, false, oWord.WdPrintOutRange.wdPrintAllDocument, printFileName }); //退出WORD wordType.InvokeMember("Quit", System.Reflection.BindingFlags.InvokeMethod, null, word, null); } /**//// <summary> /// Execl直接打印 /// </summary> /// <param name="execlfile">完整本地路径,包括文件名</param> public static void PrintExcel(string execlfile, string ExceloutputFile) ...{ Excel.ApplicationClass eapp = new Excel.ApplicationClass(); Type eType = eapp.GetType(); Excel.Workbooks Ewb = eapp.Workbooks; Type elType = Ewb.GetType(); object objelName = execlfile; Excel.Workbook ebook = (Excel.Workbook)elType.InvokeMember("Open", System.Reflection.BindingFlags.InvokeMethod, null, Ewb, new Object[] ...{ objelName, true, true }); object printFileName = ExceloutputFile; Object oMissing = System.Reflection.Missing.Value; ebook.PrintOut(oMissing, oMissing, oMissing, oMissing, oMissing, true, oMissing, printFileName); eType.InvokeMember("Quit", System.Reflection.BindingFlags.InvokeMethod, null, eapp, null); }