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?
 

Smitty

MrExcel MVP
Joined
May 15, 2003
Messages
29,536
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,
 

VoG

Legend
Joined
Jun 19, 2002
Messages
63,651
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
 

Forum statistics

Threads
1,081,749
Messages
5,361,070
Members
400,612
Latest member
mr_sound

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top