Open Print Dialog on Mac

2019-09-01 02:34发布

The VBA code below opens the print dialog on Windows but is not working on Mac Excel 2011, giving a runtime error 1004 on the line 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

Please can someone advise if there is a way to open the print dialog window on Mac Excel 2011?

1条回答
2楼-- · 2019-09-01 03:01

from here there are three options:

(Quote)

In that case, that functionality is "on the top" of the normal Print screen for Mac. "On top" both in the sense that no subordinate dialog needs to be invoked and it is above all the other options on the Print Dialog box.

or

Application.Dialogs(xlDialogPrint).Show

or

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

not having a mac to test these on, I can't vouch for their mileage

查看更多
登录 后发表回答