Macro Button--Print Page Setup

sanya02

New Member
Joined
May 31, 2007
Messages
9
How can I create a macro button that will automatically set print "Page Setup" settings for me on the sheet I am in.

It needs to set setting in Page Setup to:

Sheet: check gridlines
Margin: Center Horizontally
Page: Landscape
Fit to 1 Page

Is it possible to have this macro built in to every excel workseet I open so I could have the print settings automatically at the click of a button?
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Welcome to the Board!

You can record a macro applying the Page Setup settings you want. Just make sure to scrub the code and remove any default settings that you haven't altered. You'll want to do this because Page Setup code is very slow, so anything you can remove from the process helps tremendously.

To make the code available to any open workbook you can put it in Personal.xls. If you don't have one, you can record a new macro and in the store macro in dialog, select Personal Macro Workbook. Then stop recording, and Personal.xls will have been created for you.

Hope that helps,
 
Upvote 0
Perhaps if you mean in a single workbook then right click the Excel logo just to the left of File on the menu bar, select View Code and paste in

Code:
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
With Sh.PageSetup
    .PrintGridlines = True
    .CenterHorizontally = True
    .Orientation = xlLandscape
    .FitToPagesWide = 1
    .FitToPagesTall = 1
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,535
Messages
6,114,192
Members
448,554
Latest member
Gleisner2

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