【问题标题】:Open Print Dialog on Mac在 Mac 上打开打印对话框
【发布时间】:2013-01-14 20:53:12
【问题描述】:

下面的 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 上打开打印对话框窗口,请有人建议?

【问题讨论】:

    标签: excel vba macos


    【解决方案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 来测试这些,我不能保证他们的里程

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-20
      • 1970-01-01
      相关资源
      最近更新 更多