2013-01-14 242 views
0

下面的VBA代碼打開打印對話框上的Windows,但不工作在Mac的Excel 2011,給就行了運行時錯誤1004Application.Dialogs(xlDialogPrinterSetup).Show打開打印對話框在Mac

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

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來測試這些,我不能保證其里程