我上网查了下,好像是用printDialog,但是例子都是同一个,完全看不明白!请问哪个做过类似的东西,可以发下代码看一下吗?不胜感激!!

解决方案 »

  1.   


    // Create an Application object
    Word.ApplicationClass ac = new Word.ApplicationClass();
    Word.Application app = ac.Application;// I'm setting all of the alerts to be off as I am trying to get
    // this to print in the background
    app.DisplayAlerts = Word.WdAlertLevel.wdAlertsNone;// Open the document to print...
    object filename = "myFile.rtf";
    object missingValue = Type.Type.Missing;// Using OpenOld so as to be compatible with other versions of Word
    Word.Document document = app.Documents.OpenOld(ref filename,
    ref missingValue, ref missingValue, 
    ref missingValue, ref missingValue, ref missingValue, 
    ref missingValue, ref missingValue, ref missingValue, ref missingValue);// Set the active printer
    app.ActivePrinter = "My Printer Name";object myTrue = true; // Print in background
    object myFalse = false;// Using PrintOutOld to be version independent
    m_App.ActiveDocument.PrintOutOld(ref myTrue, 
    ref myFalse, ref missingValue, ref missingValue, ref missingValue, 
    missingValue, ref missingValue, 
    ref missingValue, ref missingValue, ref missingValue, ref myFalse, 
    ref missingValue, ref missingValue, ref m_MissingValue);document.Close(ref missingValue, ref missingValue, ref missingValue);// Make sure all of the documents are gone from the queue
    while(m_App.BackgroundPrintingStatus > 0)
    {
    System.Threading.Thread.Sleep(250);
    }app.Quitref missingValue, ref missingValue, ref missingValue);
      

  2.   

    这篇文章,也可以参考
    http://www.codeproject.com/KB/office/WordPrint.aspx
      

  3.   

    可以使用 PrintOut 方法将 Microsoft Office Word 文档(或文档的一部分)发送到打印机。可以从 Application 或 Document 对象调用 PrintOut()。打印文档下面的代码用所有默认选项打印活动文档: 
    ThisDocument.PrintOut()
    PrintOut 方法有多个可选参数,允许您微调打印文档的方式,下表概括了这些参数。参数 说明 
    Background 设置为 True 可允许在 Word 打印文档时继续处理。 
    Append 与 OutputFileName 参数一起使用。设置为 True 可将指定的文档名称追加到由 OutputFileName 参数指定的文件名后。设置为 False 将重写 OutputFileName 的内容。 
    Range 页面范围。可以为任何 WdPrintOutRange 枚举:wdPrintAllDocument、wdPrintCurrentPage、wdPrintFromTo、wdPrintRangeOfPages 或 wdPrintSelection。 
    OutputFileName 如果 PrintToFile 为 True,此参数指定输出文件的路径和文件名。 
    From Range 设置为 wdPrintFromTo 时的起始页码。 
    To Range 设置为 wdPrintFromTo 时的结束页码。 
    Item 要打印的项。可以是任何 WdPrintOutItem 枚举:wdPrintAutoTextEntries、wdPrintComments、wdPrintDocumentContent、wdPrintKeyAssignments、wdPrintProperties、wdPrintStyles。 
    Copies 要打印的份数。 
    Pages 要打印的页码和页码范围,由逗号分隔。例如,“2, 6-10”意为打印第 2 页和第 6、7、8、9、10 页。 
    PageType 要打印的页面的类型。可以是任何 WdPrintOutPages 常量:wdPrintAllPages、wdPrintEvenPagesOnly、wdPrintOddPagesOnly。 
    PrintToFile 设置为 True 可将打印机指令发送到文档。确保使用 OutputFileName 指定一个文件名。 
    Collate 打印一个文档的多个副本时使用此参数。设置为 True 则在打印下一个副本前将打印此文档的所有页面。 
    FileName 仅适用于 Application 对象。要打印的文档的路径和文件名。如果不用此参数,Word 将打印活动文档。 
    ManualDuplexPrint 设置为 True 可在打印机上没有双面打印装置的情况下打印双面文档。 常用的 PrintOut 参数。打印活动文档的第一页下面的过程打印活动文档的第一页: 
    // C#
    internal void PrintOutDoc()
    {
        object myTrue = true;
        object myFalse = false;
        object missingValue = Type.Missing;
        object range = Word.WdPrintOutRange.wdPrintCurrentPage;
        object items = Word.WdPrintOutItem.wdPrintDocumentContent;
        object copies = "1";
        object pages = "1";
        object pageType = Word.WdPrintOutPages.wdPrintAllPages;    ThisDocument.PrintOut(ref myTrue, ref myFalse, ref range,
            ref missingValue, ref missingValue, ref missingValue,
            ref items, ref copies, ref pages, ref pageType, ref myFalse,
            ref myTrue, ref missingValue,  ref myFalse, ref missingValue,
            ref missingValue, ref missingValue, ref missingValue);
    }
      

  4.   


    这个是打印一个WORD的代码吗? 呵呵 要自己研究研究阿
      

  5.   


    那具体到我要打印C:/123.doc 该怎么来写阿?
      

  6.   

       private void button1_Click(object sender, EventArgs e)        {            Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application();             object fileName = @"C:\123.doc";            object confirmConversions = Type.Missing;            object readOnly = true;            object addToRecentFiles = Type.Missing;            object passwordDoc = Type.Missing;            object passwordTemplate = Type.Missing;            object revert = Type.Missing;            object writepwdoc = Type.Missing;            object writepwTemplate = Type.Missing;            object format = Type.Missing;            object encoding = Type.Missing;            object visible = Type.Missing;            object openRepair = Type.Missing;            object docDirection = Type.Missing;            object notEncoding = Type.Missing;            object xmlTransform = Type.Missing;             Microsoft.Office.Interop.Word.Document doc = wordApp.Documents.Open(                ref fileName, ref confirmConversions, ref readOnly, ref addToRecentFiles,                ref passwordDoc, ref passwordTemplate, ref revert, ref writepwdoc,                ref writepwTemplate, ref format, ref encoding, ref visible, ref openRepair,                ref docDirection, ref notEncoding, ref xmlTransform);             wordApp.Visible = true;                        doc.PrintPreview();        }
      

  7.   

    http://topic.csdn.net/u/20100504/11/6e11a367-751e-43e0-a537-08e32947416f.html?66269
      

  8.   

    打开WORD文件
     Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application(); 
                Document doc = wordApp.Documents.Open(ref  filename, ref  oMiss, ref  readOnly, ref  oMiss, ref  oMiss, ref  oMiss, ref  oMiss, ref  oMiss, 
                ref  oMiss, ref  oMiss, ref  oMiss, ref  oMiss, ref  oMiss, ref  oMiss, ref  oMiss, ref  oMiss);            doc.Activate();  
                doc.Application.PrintPreview = true; 
              doc.Application.ActiveDocument.PrintPreview();