【问题标题】:How to show print dialog box and print preview on same screen?如何在同一屏幕上显示打印对话框和打印预览?
【发布时间】:2016-03-07 02:06:58
【问题描述】:

我正在尝试在 Excel 2013 中模拟 Ctrl-P,其中左侧显示打印对话框,右侧显示打印预览。

(虽然预览显示在哪里,但我总是必须先点击“显示打印预览”。我找不到每次都强制显示预览的方法。

我尝试了以下方法:

Application.Dialogs(xlDialogPrint).Show

这显示了您需要单击“预览”按钮的旧样式对话框

ActiveSheet.PrintPreview

这会显示预览,但不允许从同一屏幕更改打印机。

【问题讨论】:

    标签: excel vba outlook ms-word print-preview


    【解决方案1】:

    像这样的?

    Excel

    Option Explicit
    Public Sub Example()
        Application.CommandBars.ExecuteMso ("PrintPreviewAndPrint")
    End Sub
    

    CommandBars.ExecuteMso Method (MSDN) 在特定命令没有对象模型的情况下非常有用。

    对于 Outlook

    Option Explicit
    Public Sub Example()
        Dim Inspector As Outlook.Inspector
        Set Inspector = Application.ActiveInspector
    
        If Not Inspector Is Nothing Then
            Dim cmd As Office.CommandBars
            Set cmd = Inspector.CommandBars
    
            cmd.ExecuteMso ("FilePrintPreview")
        Else
            ActiveExplorer.selection(1).Display
            Set cmd = ActiveInspector.CommandBars
            cmd.ExecuteMso ("FilePrintPreview")
        End If
    End Sub
    

    【讨论】:

    • 好的,谢谢!我很惊讶我在任何地方都找不到,我以为会有更多的人想做同样的事情。
    • 引号中的文本不需要括号,因此请使用Application.CommandBars.ExecuteMso "PrintPreviewAndPrint",尽管宏记录器和在线文档显示。
    猜你喜欢
    • 2015-07-05
    • 2015-01-22
    • 1970-01-01
    • 1970-01-01
    • 2013-04-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多