How to reset printer FitToPages settings back to normal in vba

Jeddo

Board Regular
Joined
Jan 26, 2019
Messages
50
Office Version
  1. 2019
Platform
  1. Windows
I have a workbook with several worksheets that have multiple ranges that I print out individually, all needing different printer settings. Haven't had any problems till now.
One of the ranges required that the range print to one page. I figured out how to use FitToPages settings to get it to fit to the page and it works fine. Problem is, now everything prints to one page and I can't figure out how to turn it off. Preferably, I need a code to add to the code below that would reset the FitToPages back to normal after the printing is over. Or a code to embed in all my other printer settings to turn off the fit to page. I've tried everything my limited brain can imagine to no avail. Any help would be appreciated.


With Sheet1
Application.PrintCommunication = False
With .PageSetup

.BottomMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0#)
.TopMargin = Application.InchesToPoints(0.5)
.HeaderMargin = Application.InchesToPoints(0#)
.LeftMargin = Application.InchesToPoints(0.25)
.RightMargin = Application.InchesToPoints(0.25)
.FitToPagesWide = 1
.FitToPagesTall = 1
.PrintArea = Sheet1.Range("BA5:BB61").Address

End With
Application.PrintCommunication = True
End With

Range("BA5", Range("BB8").End(xlDown)).PrintOut
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Have you tried recording a Macro of it while you do it manually...
 
Upvote 0
Have you tried recording a Macro of it while you do it manually...
No, I haven't. I've got all of my print ranges set up on command buttons and just edited the settings for each range, which was mostly borders or orientation. One range had a variable in the number of rows and I needed it to print all to one page. Scouring this forum, I added the FitToPages in my printer settings for that range and it worked great, but it screwed it up for everything else. Now everything is printing to one page and I can't figure out how to get it set back to the way it was.
 
Upvote 0
Perhaps you may want to try it, so you can see what the result is. Do it on a copy of your book...
 
Upvote 0

Forum statistics

Threads
1,214,956
Messages
6,122,465
Members
449,085
Latest member
ExcelError

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