在横向中另存为PDF

时间:2014-04-16 19:51:54

标签: excel-vba vba excel

如何将我的工作簿中的多张工作表pdf成横向格式的pdf格式?这就是我所拥有的。我错过了横向语法 -

Sub CompileReport()

    Sheets(Array("Sheet1", "Sheet2", "Sheet3")).Select

    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="F:\Report\Test" & ".pdf", _
    Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False


End Sub

谢谢!

1 个答案:

答案 0 :(得分:5)

试试这个:

Sub CompileReport()
    Dim mySheets As Variant, sh

    mySheets = Array("Sheet1", "Sheet2", "Sheet3")
    For Each sh In mySheets
        Sheets(sh).PageSetup.Orientation = xlLandscape
    Next

    Sheets(mySheets).Select
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="F:\Report\Test" & ".pdf", _
        Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False
End Sub