我正在尝试在 Excel 2013 中模拟 Ctrl-P,其中打印对话框显示在左侧,打印预览显示在右侧。
(虽然预览显示在哪里,但我总是必须先单击“显示打印预览”。我找不到强制每次都显示预览的方法。
我尝试了以下方法:
Application.Dialogs(xlDialogPrint).Show
这显示了旧式对话框,您需要在其中单击“预览”按钮
ActiveSheet.PrintPreview
这会显示预览,但不允许从同一屏幕更改打印机。
最佳答案
类似这样的东西吗?
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
关于excel - 如何在同一屏幕上显示打印对话框和打印预览?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35835084/