Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Protecting Print Settings.

Protecting Print Settings

Written by Allen Wyatt (last updated April 1, 2023)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021


Sharing an Excel workbook with a group also means being involved with different printers, different PCs and different user requirements and expectations. This is nowhere more apparent then when it comes to printing a worksheet. Different users obviously have different PCs and may have different printers, so the printed results can vary from one user to another. In addition, different users may change the print ranges in what is produced from a worksheet.

If you are responsible for a particular worksheet, you may want to somehow protect the various print settings you've established so that they aren't garbled by other users. Perhaps the easiest way to do this is to save your print settings in a macro, and then run that macro every time the workbook is closed. In that way, the settings can be changed back to the "defaults" you specify, without worry that users will mess them all up.

For instance, the following macro shows how you can set all the print settings for a particular print job:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
    With ActiveSheet.PageSetup
        .LeftHeader = ""
        .CenterHeader = ""
        .RightHeader = ""
        .LeftFooter = ""
        .CenterFooter = ""
        .RightFooter = ""
        .LeftMargin = Application.InchesToPoints(1)
        .RightMargin = Application.InchesToPoints(1)
        .TopMargin = Application.InchesToPoints(1)
        .BottomMargin = Application.InchesToPoints(1)
        .HeaderMargin = Application.InchesToPoints(0.5)
        .FooterMargin = Application.InchesToPoints(0.5)
        .PrintHeadings = False
        .PrintGridlines = False
        .PrintComments = xlPrintNoComments
        .CenterHorizontally = False
        .CenterVertically = False
        .Orientation = xlPortrait
        .Draft = False
        .PaperSize = xlPaperLetter
        .FirstPageNumber = xlAutomatic
        .Order = xlDownThenOver
        .BlackAndWhite = False
        .Zoom = False
        .FitToPagesWide = 1
        .FitToPagesTall = 99
        .PrintErrors = xlPrintErrorsDisplayed
        .PrintArea = "MyPrintArea"
        .PrintTitleRows = ""
        .PrintTitleColumns = ""
    End With
End Sub

This macro is an event handler, and it should be saved within the ThisWorkbook object in the VBA Editor. To make the macro work for your particular needs, simply modify the settings to match whatever your requirements are. You can also have the settings apply to a specific worksheet by substituting the name of the worksheet for the ActiveSheet object. Here are two examples:

    With Worksheets(1).PageSetup
    With Worksheets("Report").PageSetup

The first of these would work on the first worksheet in the workbook, while the second would work on the worksheet named "Report".

Of course, when someone else opens your workbook, the macro may be disabled automatically or they may see a notification that there are macros in it. If they choose to disable the macros, then your default-setting macro won't run when the workbook is closed. The solution, of course, is for you to open the workbook, enable the macros, and then close the workbook. This runs the macro and your settings are again restored as you want them.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (11599) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021. You can find a version of this tip for the older menu interface of Excel here: Protecting Print Settings.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Workbook Events

You can create macros that run whenever Excel detects a certain event happening within an entire workbook. This tip ...

Discover More

Finding the Size of a Workbook

Keeping tabs on the size of a workbook can be important when using Excel. You have a couple of options that will allow ...

Discover More

Selecting a Column or Row in a Table

Selecting rows and columns in tables is a common task. Because of this, Word provides a couple of ways you can accomplish ...

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

More ExcelTips (ribbon)

Printing a Short Selection

Need to print just a portion of a worksheet? It's easy to do if you follow the steps in this tip.

Discover More

Working with Multiple Printers

If you have multiple printers accessible to your computer, you may need a way to quickly print your worksheet on a ...

Discover More

Printing a Draft Watermark

Adding a watermark to the background of a printout can be challenging. This tip explains the different ways you can ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is nine minus 5?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.