And*_*rew 4 excel outlook vba ms-word print-preview
我试图Ctrl-P在 Excel 2013 中模拟,其中打印对话框显示在左侧,打印预览显示在右侧。
(尽管预览显示的位置,我总是必须先单击“显示打印预览”。我找不到强制每次都显示预览的方法)。
我尝试了以下方法:
Application.Dialogs(xlDialogPrint).Show
Run Code Online (Sandbox Code Playgroud)
这将显示您需要单击“预览”按钮的旧样式对话框
ActiveSheet.PrintPreview
Run Code Online (Sandbox Code Playgroud)
这会显示预览,但不允许从同一屏幕更改打印机。
像这样的东西?
电子表格
Option Explicit
Public Sub Example()
Application.CommandBars.ExecuteMso ("PrintPreviewAndPrint")
End Sub
Run Code Online (Sandbox Code Playgroud)
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
Run Code Online (Sandbox Code Playgroud)