Print to PDF only selected area, remove white spaces

Status
Not open for further replies.

lilloscar

New Member
Joined
Nov 27, 2016
Messages
37
I have this code, and I can't print only one column (first green selection), what setting do you think I'm missing in the page-setup?

My data actually is at the column O1:O

Example:
fetch


Code:
Code:
Sub PrintPDF()

Dim LastCellRow
LastCellRow = ActiveSheet.Range("A60").End(xlUp).Row
While Cells(LastCellRow, 60) = "."
LastCellRow = LastCellRow - 1
Wend

    strDir = "C:\Users\Carlos Hernandez\Google Drive\Cano Roofing\IMGENES\"
    
    If Dir(strDir, vbDirectory) = "" Then

With ActiveSheet
.PageSetup.PrintArea = Range("O1", Cells(LastCellRow, 15)).Address '"$A$7:$A$50"
With ActiveSheet.PageSetup
    .LeftMargin = Application.InchesToPoints(0.5)
    .RightMargin = Application.InchesToPoints(0.1)
    .TopMargin = Application.InchesToPoints(0.5)
    .BottomMargin = Application.InchesToPoints(0.5)
    .HeaderMargin = Application.InchesToPoints(0.5)
    .FooterMargin = Application.InchesToPoints(0.5)
    .PrintHeadings = False
    .CenterHorizontally = False
    .CenterVertically = False
    .Orientation = xlLandscape
    .PaperSize = xlPaperLetter
    .FitToPagesWide = 1
    .FitToPagesTall = 1
End With
.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:="C:\Users\Carlos Hernandez\Google Drive\Cano Roofing\IMGENES\Personal.pdf", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=True
End With

End Sub
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Status
Not open for further replies.

Forum statistics

Threads
1,224,851
Messages
6,181,395
Members
453,034
Latest member
mikdadhussain

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top