Print to PDF only selected area, remove white spaces

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?

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

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
I don't know what "first green selection" means. After the pagesetup, what does an Immediate Window show after a run for the printarea?
Code:
.PageSetup.PrintArea = Range("O1", Cells(LastCellRow, 15)).Address '"$A$7:$A$50"
Debug.Print .PageSetup.PrintArea
 
Upvote 0
Cross posted. Please provide links to the other sites you have asked this question on.

While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 
Upvote 0
I don't know what "first green selection" means. After the pagesetup, what does an Immediate Window show after a run for the printarea?
Code:
.PageSetup.PrintArea = Range("O1", Cells(LastCellRow, 15)).Address '"$A$7:$A$50"
Debug.Print .PageSetup.PrintArea
Hello! the green area that I need to print is showed in my attached image, I want to remove all that white space and I think is because I need to change the size of the paper, for example I printed the attached file in a paper of size of 2 inches x 17 inches and thats the result of the column O1:O
Please take a look: https://drive.google.com/file/d/1WkFoodsfuBHsswuhnOvvOf6ecCwrxWgK/view?usp=sharing


Cross posted. Please provide links to the other sites you have asked this question on.

While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.

I asked the same in two forums to get a faster answer, I know is wrong but is to save time to get it done https://www.ozgrid.com/forum/forum/...to-pdf-only-selected-area-remove-white-spaces
 
Upvote 0
I solved this just by zooming the print area and selected a type of paper with less width, now one column cover all the width of the PDF, I have a lot of Pages but it's OK

Code:
.PageSetup.Zoom = 400
.PaperSize = xlPaperEnvelopeItaly
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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