how to access programmatically to “print preview a

2019-07-29 22:29发布

I am writing a medical program (with C# Language) which has a relation with Microsoft Office Word 2010. In Word 2010 there is a page "Print Preview and Print" which you can access by pressing Ctrl+P. After I launch Office Word, I want to see "Print Preview and Print" but instead I see the old print preview from Office 2007/2003, which means I don't know how to access this page from office com objects.

The code I've tried:

oWordDoc.PrintPreview();
_oWord.Visible = true;

2条回答
SAY GOODBYE
2楼-- · 2019-07-29 23:17

You can always try SendKeys to do the same as the hotkey CTRL+P

SendKeys.Send("^P");
查看更多
你好瞎i
3楼-- · 2019-07-29 23:30

Try

int dialogResult = wordApp.Dialogs[Word.WdWordDialog.wdDialogFilePrint].Show(ref missing);
if (dialogResult == 1)
{
    oWordDoc.PrintOut(ref missing, ref missing, ref missing, ref missing,
                      ref missing, ref missing, ref missing, ref missing,
                      ref missing, ref missing, ref missing, ref missing,
                      ref missing, ref missing, ref missing, ref missing,
                      ref missing, ref missing);
}
查看更多
登录 后发表回答