Search code examples
c#.netwinformsms-wordoffice-interop

Interop.Word print preview dialog for office 2010/2013


In my application I have word template with tags which are later replaced using interop.word (find/replace) and then sent to print using print preview dialog: Interop.Word.Application.Dialogs[WdWordDialog.wdDialogFilePrint]

On a result of a dialog I am printing or closing the document.

For office 2003 and 2007 this is working absolutely fine, but in office 2010 later print preview dialog is absolutely different.

I've found related post here but I need to grab dialog result so that i could further do print or close the doc.

Is there any workaround or soultions for that?


Solution

  • Just for the future reference posting answer to my own question. Finally I could figure it out.

    Following code is working with any version of Word fine. While dialog is open application freezes and waits for a result just as another dialogs.

    The only moment is it allows to choose appropriate printer only, but does not show preview.

                 _doc.Activate();
                 _wordApp.Visible = true;
    
                 var dialogResult = _wordApp.Dialogs[WdWordDialog.wdDialogFilePrint].Show();
    
                 if (dialogResult == 1)
                     _doc.PrintOut();