Print Page Using VBA in Excel

Davis10

New Member
Joined
Jun 21, 2011
Messages
27
I have been trying to print the worksheet using a command button. As of now I have the code :

Private Sub CommandButton2_Click()
Dim wSht As Worksheet
Set wSht = Worksheets("Define COAs")
With wSht.PageSetup
.PrintArea = "$A$1:$G$12"
.PaperSize = xlPaperLetter
.Orientation = xlLandscape
.FitToPagesWide = 1
.FitToPagesTall = 1
End With
wSht.PrintOut
End Sub

This works to print out my worksheet but it prints on two pages and I need it to print on only one page. Any Ideas on how I can do this?
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
I just had a similar situation. I had originally recorded a macro to handle the printing, but within the "With...End With" block, it had dozens of entries that were not needed and made my script run very long. I removed the lines I thought weren't needed and it worked fine except it did not keep everything on 1 page wide, even though I had:
.FitToPagesWide = 1
.FitToPagesTall = False

What fixed it was to add:
.Zoom = False

Try that and see if it fixes things.
 
Upvote 0

Forum statistics

Threads
1,224,582
Messages
6,179,670
Members
452,936
Latest member
anamikabhargaw

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