简体   繁体   中英

excel VBA PDF print eparating with horizontal page breaks

I have a worksheet that has 160 pages in it. One set of data could have 3 pages followed by a horizontal page breaks. I am trying to figure out how to make a separate PDF after each horizontal page break and name it as the string in cell A (it is the same name down) of that page break.

This is where I am at with the export to pdf, missing the above.

Sub Print_PDF()
Dim Awb As Workbook
Dim Snr As Integer
Dim ws As Worksheet
Set Awb = ActiveWorkbook


For Each ws In Awb.Sheets
    If ws.Visible = xlSheetVisible Then

    'Sheets(ws.Name).Copy
    Awb.Sheets(ws.Name).Copy
    'Sheets(ws.Name).Select
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, filename:= _
    Awb.Path & "\" & Awb.Sheets(ws.Name).Name & ".pdf", _
    Quality:=xlQualityStandard, IncludeDocProperties:=True, _
    IgnorePrintAreas:=False, OpenAfterPublish:=False

    ActiveWindow.Close False
End If

Next ws

End Sub

Are you saying you have a workbook with 160 worksheets in it? Or a workbook with 1 worksheet in it with 160 sets of data on the one sheet?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM