在Mac上打开打印对话框

时间:2013-01-14 20:53:12

标签: vba excel-vba-mac

下面的VBA代码在Windows上打开打印对话框,但在Mac Excel 2011上无效,在行Application.Dialogs(xlDialogPrinterSetup).Show

上显示运行时错误1004
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上打开打印对话框窗口?

1 个答案:

答案 0 :(得分:1)

来自here

有三个选项:

引用

  

在这种情况下,该功能位于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来测试这些,我不能保证他们的里程