下面的VBA代码在Windows上打开打印对话框,但在Mac Excel 2011上无效,在行Application.Dialogs(xlDialogPrinterSetup).Show
Private Sub cbPrint_Click()
Dim Caption As String
If formPrintOptions.Frame1.ActiveControl.Value Then
Caption = formPrintOptions.Frame1.ActiveControl.Caption
formPrintOptions.Hide
Application.Dialogs(xlDialogPrinterSetup).Show
Select Case Caption
Case "Id1"
ThisWorkbook.Sheets(Array("FrontPage", "Id1")).PrintOut Preview:=True
Case "Id2"
ThisWorkbook.Sheets(Array("FrontPage", "Id2")).PrintOut Preview:=True
Case "Id3"
ThisWorkbook.Sheets(Array("FrontPage", "Id3")).PrintOut Preview:=True
Case "Id4"
ThisWorkbook.Sheets(Array("FrontPage", "Id4")).PrintOut Preview:=True
Case Else
End Select
Else
MsgBox "None selected"
End If
Unload formPrintOptions
End Sub
有人可以建议是否有办法在Mac Excel 2011上打开打印对话框窗口?
答案 0 :(得分:1)
有三个选项:
(引用)
在这种情况下,该功能位于Mac正常打印屏幕的“顶部”。 “在顶部”两者都意味着不需要调用从属对话框,并且它首先是“打印”对话框中的其他选项。
或
Application.Dialogs(xlDialogPrint).Show
或
MsgBox MacScript(PrintSetupMacScript())
Function PrintSetupMacScript() As String
PrintSetupMacScript = "try"
PrintSetupMacScript = PrintSetupMacScript & vbLf & "tell application ""System Preferences"" "
PrintSetupMacScript = PrintSetupMacScript & vbLf & " reveal pane ""Print & Fax"" "
PrintSetupMacScript = PrintSetupMacScript & vbLf & " activate"
PrintSetupMacScript = PrintSetupMacScript & vbLf & " repeat while (name of window 1) = ""Print & Fax"" "
PrintSetupMacScript = PrintSetupMacScript & vbLf & " end repeat"
PrintSetupMacScript = PrintSetupMacScript & vbLf & "end tell"
PrintSetupMacScript = PrintSetupMacScript & vbLf & "return true"
PrintSetupMacScript = PrintSetupMacScript & vbLf & "on error"
PrintSetupMacScript = PrintSetupMacScript & vbLf & "return false"
PrintSetupMacScript = PrintSetupMacScript & vbLf & "end try"
End Function
没有mac来测试这些,我不能保证他们的里程