Results 1 to 6 of 6

Thread: Solved: Error while printing pdf from excel

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    VBAX Tutor
    Joined
    Jan 2008
    Posts
    262
    Location
    Hi Abraham, this should address the print area issue and saving to PDF

    [VBA]Sub pdf_doc()

    Dim lr As Long
    Dim lc As Long
    Dim Printrng As Range

    lr = Cells(Rows.Count, 8).End(xlUp).Row
    lc = Cells(11, Columns.Count).End(xlToLeft).Column

    Set Printrng = Range(Cells(1, 1), Cells(lr, lc))

    With ActiveSheet.PageSetup
    .PrintArea = Printrng.Address
    .PrintTitleRows = "$1:$10"
    .CenterFooter = "&P/&N"
    .PrintQuality = 600
    .Zoom = False
    .FitToPagesWide = 1
    .FitToPagesTall = False
    End With

    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    "C:\Users\Public\saabx.pdf", Quality:=xlQualityStandard, _
    IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True

    End Sub
    [/VBA]
    Last edited by sassora; 03-09-2013 at 11:59 AM. Reason: Saving part sorted - the was a permissions issue when saving to my C drive

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •