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. #1

    Solved: Error while printing pdf from excel

    Hello Everyone,

    With the help of this forum, I got my solution to print pdf from excel spreadsheet with variable range.
    But I got error no 41 in the line .PrintArea = lc & lr

    Can anyone help me with my attached spreadsheet. (Also can I get the same output in word document format along with pdf)

    [vba]
    Sub pdf_doc()
    Dim lr As Long, lc As Long
    lr = Cells(Rows.Count, 8).End(xlUp).Row
    lc = Cells(Columns.Count, 8).End(xlToLeft).Column
    With ActiveSheet.PageSetup
    .PrintArea = lc & lr
    .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]

    Advance thanks
    Attached Files Attached Files
    Last edited by Aussiebear; 03-09-2013 at 02:35 AM. Reason: Corrected the tags surrounding the code

Posting Permissions

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