如何在同一屏幕上显示打印对话框和打印预览?

发布于 2025-01-12 10:07:48 字数 336 浏览 1 评论 0原文

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

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

我尝试了以下操作:

Application.Dialogs(xlDialogPrint).Show

这显示了旧式对话框,您需要在其中单击“预览”按钮

ActiveSheet.PrintPreview

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

I am trying to emulate Ctrl-P in Excel 2013 where the print dialog box is shown on the left with the print preview on the right.

(Although where the preview displays, I always have to click "Show Print Preview" first. I can't find a way to force the preview to show every time).

I tried the following:

Application.Dialogs(xlDialogPrint).Show

This shows the old style dialog box where you need to click the "Preview" button

ActiveSheet.PrintPreview

This shows the preview but doesn't allow the printer to be changed from the same screen.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浪菊怪哟 2025-01-19 10:07:48

类似这样的东西吗?

Excel

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

CommandBars.ExecuteMso 方法 (MSDN) 在特定命令没有对象模型的情况下是有用的方法。

对于展望

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

Something like this?

Excel

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

CommandBars.ExecuteMso Method (MSDN) is useful method in cases where there is no object model for a particular command.

For 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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文