在PC和Mac上将工作表另存为PDF

时间:2017-02-28 09:35:15

标签: excel macos pdf

试图获得一个简单的功能"将活动表保存为PDF"在Apple Mac Office 2016上运行我遇到了以下代码。

然而,虽然它在Windows上完美运行,但它在Mac上失败并且打印时出现错误 - 打印错误#34;消息后跟运行时错误1004:方法' ExportAsFixedFormat'对象' _Worksheet'失败。

我尝试了很多变化,但似乎都没有。

Sub CreatePDF()
Dim wksSheet As Worksheet
Dim TheOS As String

TheOS = Application.OperatingSystem

If InStr(1, TheOS, "Windows") > 0 Then
  Set wksSheet = ActiveSheet
        wksSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
                ThisWorkbook.Path & "\" & "Sheet1 on Windows", Quality:=xlQualityStandard, _
                IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
                False
        Exit Sub

Else
  Set wksSheet = ActiveSheet
        wksSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
                ThisWorkbook.Path & ":" & "Sheet1 on Mac", Quality:=xlQualityStandard, _
                IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
                False
        Exit Sub
   End If

0 个答案:

没有答案
相关问题