Disabling Printing

Written by Allen Wyatt (last updated February 24, 2024)
This tip applies to Excel 97, 2000, 2002, and 2003


If you are creating workbooks to be used by others, you may be interested in disabling the print options (menu and toolbar) whenever a specific workbook is open. The easiest way to do so is to use the Auto_Open macro (which runs immediately upon opening the workbook that contains it) to make the menu and toolbar printing commands no longer available. The following will do the trick nicely:

Sub Auto_Open()
    'Prevent Printing via menu
    MenuBars(xlWorksheet).Menus("File").MenuItems("Print...").Delete

    'Turn off Print icon wherever it may be in the toolbars
    For J = 1 To Toolbars.Count
        For K = 1 To Toolbars(J).ToolbarButtons.Count
            If Toolbars(J).ToolbarButtons(K).Id = 2 Then
                Toolbars(J).ToolbarButtons(K).Enabled = False
            End If
            If Toolbars(J).ToolbarButtons(K).Id = 3 Then
                Toolbars(J).ToolbarButtons(K).Enabled = False
            End If
        Next K
    Next J
End Sub

You can also create a special Auto_Close macro that restores the menus and toolbars when the workbook is closed:

Sub Auto_Close()
    'Reset the menu items
    For Each mb In MenuBars
        mb.Reset
    Next mb

    'Reset the buttons
    For J = 1 To Toolbars.Count
        For K = 1 To Toolbars(J).ToolbarButtons.Count
            If Toolbars(J).ToolbarButtons(K).Id = 2 Then
                Toolbars(J).ToolbarButtons(K).Enabled = True
            End If
            If Toolbars(J).ToolbarButtons(K).Id = 3 Then
                Toolbars(J).ToolbarButtons(K).Enabled = True
            End If
        Next K
    Next J
End Sub

You should note that these macros only run when the specific workbook is opened and closed. That means that your printing capability will be unavailable as long as the workbook is open—even for any other open workbooks you may have.

Another approach is to cancel any printing before it starts. The following is a macro you can place within a workbook module:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
    Cancel = True
End Sub

Whenever someone tries to print the workbook, the process is automatically cancelled. Otherwise, the menu choices and toolbar buttons remain visible. (You could also change the macro to not only cancel but to display a message box indicating that users are not allowed to print.)

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 (2556) applies to Microsoft Excel 97, 2000, 2002, and 2003.

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

Running a Macro when a Worksheet is Activated

Want to run a macro when you first select a worksheet? You can do so by using one of the event handlers built into Excel, ...

Discover More

Develop Macros in Their Own Workbook

If you develop macros and edit them quite a bit, you may be running the risk of causing problems with the macros or with ...

Discover More

Saving AutoText Entries with Each Document

AutoText can be a great way to add consistent, common text to a document. Unfortunately, you cannot save AutoText entries ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More ExcelTips (menu)

Printing Multiple Worksheets on a Single Page

Got a bunch of worksheets and you want to save paper by printing multiple worksheets on a single piece of paper? There ...

Discover More

Printing Workbook Properties

Want to create a printed record of the properties associated with a workbook? There is no easy way to do it in Excel. ...

Discover More

Non-Printing Controls

Don't want your form controls to print out with your worksheet? Here's how to make sure that Excel excludes them from the ...

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 6 - 0?

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 menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon 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.