Vkonca
Vkonca

Reputation: 33

Selected Range Save As PDF

With Excel VBA, for example, I want to save the area between A1 and J26 as pdf, but since it doesn't fit, it saves A1 to E26.What should I do to save my chosen area by fitting it on the page? The code I use is below.

With Sheets(1).Range("A1:J26")
   .ExportAsFixedFormat _
    Type:=xlTypePDF, _
    Filename:="C:\File_Name_Test.pdf", _
    Quality:=xlQualityStandard, _
    IncludeDocProperties:=True, _
    IgnorePrintAreas:=False, _
    OpenAfterPublish:=False '
End With

Upvotes: 0

Views: 118

Answers (1)

Vkonca
Vkonca

Reputation: 33

The code below saw my work, thanks

With Sheets("Sayfa1").PageSetup
.Orientation = xlPortrait
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
.PrintErrors = xlPrintErrorsDisplayed
.ScaleWithDocHeaderFooter = True
.AlignMarginsHeaderFooter = True
End With

With Sheets("Sayfa1").Range("A1:J22")
.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:="D:\_AppData_\Desktop\File_Name22.pdf", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False '
End With

Upvotes: 2

Related Questions