none
Word 2007 printing from C#

    Question

  •   Hi,

    I am trying to print using Word 2007 from C#, and I can see it go to the printer but nothing comes out, it just dissapears from the printer pool. I think the Print server must think there is no content to print so deletes, but can't workout what is missing.

    My code is:

    using Microsoft.Office.Interop.Word;

    object oTemplate = "c:\\temp\\template.dotx";

    object readOnly = false;

    object isVisible = true;

    object missing = System.Reflection.Missing.Value;

    Microsoft.Office.Interop.Word.ApplicationClass oWordApp = new Microsoft.Office.Interop.Word.ApplicationClass();

    Microsoft.Office.Interop.Word.Document oWordDoc = oWordApp.Documents.Add(ref oTemplate, ref readOnly, ref readOnly, ref isVisible);

    oWordDoc.Activate();

    //Print

    Object background = true;

    Object append = Type.Missing;

    Object range = Microsoft.Office.Interop.Word.WdPrintOutRange.wdPrintAllDocument;

    Object outputFileName = Type.Missing;

    Object from = Type.Missing;

    Object to = Type.Missing;

    Object item = Microsoft.Office.Interop.Word.WdPrintOutItem.wdPrintDocumentContent;

    Object copies= 1;

    Object pages = "";

    Object pageType = Microsoft.Office.Interop.Word.WdPrintOutPages.wdPrintAllPages;

    Object printToFile = false;

    Object collate = true;

    Object fileName = "";

    Object activePrinterMacGX = Type.Missing;

    Object manualDuplexPrint = false;

    Object printZoomColumn = 0;

    Object printZoomRow = 0;

    Object printZoomPaperWidth = 0;

    Object printZoomPaperHeight = 0;

    oWordDoc.Application.ActivePrinter = \\\\Jupitor\\HP550 on Ne03:;

    oWordDoc.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 activePrinterMacGX,

    ref manualDuplexPrint, ref printZoomColumn,

    ref printZoomRow, ref printZoomPaperWidth, ref printZoomPaperHeight);

    ///////////////////////////////////////

    Can you tell me what I am missing?

    Many thanks

    Brett

    Friday, November 28, 2008 4:16 PM

Answers