abraham30
03-08-2013, 10:02 PM
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)
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
Advance thanks
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)
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
Advance thanks