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
Last edited by Aussiebear; 03-09-2013 at 02:35 AM.
Reason: Corrected the tags surrounding the code
Thanks for your valuable comment. I don't know, might be silly for you. If the spreadsheet is saved in a particular path, then can we create the process.