Printing to PDF, but not catching the whole page

krazy08

New Member
Joined
Dec 23, 2014
Messages
6
Hello All,

Apologies in advance for the long type to follow...

But I have a situation where I thought I had the PageSetup going smooth. But the product I receive is just a snippet of what I am after and it keeps slicing my tables off at the page breaks. See Code Below↓ I left out the codes for coloring as it was a bit much, but basically everything surrounding the tables is vbCYAN which is what I'm trying to preserve.

I have attached links to what is my result vs. what I am after.
Bad (Table on bottom is cutoff and no blue to be found): http://i.imgur.com/RagFiU0.jpg
Good (Cyan all around is preserved): http://i.imgur.com/B4i843F.png

Code:
Sub Xlsx2PDF_EntirePageFormat 

'Excel's Page Setup[INDENT]Dim File       As String
Dim Path      As String[/INDENT]
[INDENT]    With ActiveSheet.PageSetup[/INDENT]
[INDENT]                   .PrintGridlines = True[/INDENT]
[INDENT]                   .Orientation = xlPortrait[/INDENT]
[INDENT]                   .PaperSize = xlPaperLetter[/INDENT]
[INDENT]                   .FirstPageNumber = xlAutomatic[/INDENT]
[INDENT]                   .Order = xlDownThenOver[/INDENT]
[INDENT]                   .BlackAndWhite = False[/INDENT]
[INDENT]                   .Zoom = False[/INDENT]
[INDENT]                   .FitToPagesWide = 1[/INDENT]
[INDENT]                   .FitToPagesTall = False[/INDENT]
[INDENT]                   .PrintErrors = xlPrintErrorsDisplayed[/INDENT]
[INDENT]   End With  

[/INDENT]
'Print 2 PDF Page Setup[INDENT]   With ActiveWorkbook[/INDENT]
[INDENT]       Path = "C:\Users\MyComp\Desktop\New folder\"[/INDENT]
[INDENT]       For Each ws In .Worksheets[/INDENT]
[INDENT]               File = ws.Range("B1").Value & ".pdf"[/INDENT]
[INDENT]               ws.ExportAsFixedFormat Type:=xlTypePDF, _[/INDENT]
[INDENT]                                       Filename:=Path & File, _[/INDENT]
[INDENT]                                       Quality:=xlQualityStandard, _[/INDENT]
[INDENT]                                       IncludeDocProperties:=False, _[/INDENT]
[INDENT]                                       IgnorePrintAreas:=False, _[/INDENT]
[INDENT]                                       OpenAfterPublish:=False[/INDENT]
[INDENT=2]       Next ws
End With[/INDENT]
End Sub


In the code I have played with the:
zoom = 100 or False​
.FitToPagesTall = 1 or False​
etc and it makes no difference. It just seems to be only going for the Main work area and ignoring everything else at export time! If it's not too much trouble is there an easy code for "Page Breaks" to attach somewhere?? Any help is greatly appreciated, Thanks.

 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Ok it was actually simple to take care of "Page Breaking"

Code:
'Set Page Break
        
            ThisWorkbook.ActiveSheet.Rows(50).PageBreak = xlPageBreakManual

But the Color Preservation is still an issue :S
 
Upvote 0
Have you set the print area?

More to the point, have you recorded a macro that gives you the result you want?
 
Upvote 0
Hey shg,

No, even "Print to PDF" manually does not give me the result I want. I was hoping VBA could force it to do it. But it looks ugly and cumbersome to achieve. I actually found another vba color scheme code and am satisfied enough to let this one go. Thanks for responding though! Happy New Year!

krazy08
 
Upvote 0

Forum statistics

Threads
1,215,632
Messages
6,125,909
Members
449,274
Latest member
mrcsbenson

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