Printing Problems

How to Lock Print Area and Print Settings in Excel

Huda QurayshiHuda Qurayshi Nov 3, 2026 870 views

Question details

The user wants to know how to prevent other users from changing the predefined print area, paper size, and page setup settings in an Excel worksheet.

How to Lock Print Area and Print Settings in Excel
Product
Microsoft Excel
Device & OS
not provided
Scenario
Sharing a formatted Excel workbook where specific print configurations need to remain consistent and unchanged by other users.
Observed behavior
Excel's native worksheet protection features do not lock the print area or page setup settings, allowing any user to alter the print layout.
Before you start

Ensure that your workbook is saved as a Macro-Enabled Workbook (.xlsm), as you will need to use Visual Basic for Applications (VBA) to enforce locked print settings.

Solution 1Recommended

Use a VBA Macro to Enforce Print Settings

Since Excel does not have a built-in toggle to lock page setup configurations, you can use a macro to reset the print area and page size to your preferred defaults whenever the workbook is opened or printed.

A VBA event handler can automatically restore your preferred print settings every time the workbook is interacted with. By combining this with VBA project protection, you ensure users cannot bypass the predefined print layout.

1
Open the VBA Editor

Launch your Excel workbook and press 'Alt + F11' on your keyboard to open the Visual Basic for Applications (VBA) editor.

2
Access the Workbook Module

In the Project Explorer pane on the left side of the VBA editor, locate your file name and double-click on 'ThisWorkbook' to open its code window.

3
Insert the Macro Code

Paste a VBA script using the Workbook_BeforePrint event. For example, add 'ActiveSheet.PageSetup.PrintArea = "$A$1:$F$20"' to force the print area to that specific range right before printing occurs.

4
Protect the VBA Project

To prevent users from deleting your code, click 'Tools' in the top menu, select 'VBAProject Properties', go to the 'Protection' tab, check 'Lock project for viewing', and set a password.

5
Save as a Macro-Enabled Workbook

Close the VBA editor. Go to 'File' > 'Save As' and choose 'Excel Macro-Enabled Workbook (*.xlsm)' from the file type dropdown menu to ensure your code is retained.

Macro Security Requirement: Users must enable macros when opening the workbook for this protection method to function. If macros are disabled, the print settings will remain editable.
Effortless Spreadsheet Management

Manage Print Areas and VBA Macros with WPS Office

WPS Office Spreadsheet provides robust support for customizing print areas and running VBA macros, making it incredibly easy to manage and protect your document layouts. It is fully compatible with Microsoft Excel formats, including macro-enabled workbooks.

  1. 1. Open your file in WPS Spreadsheet: Launch WPS Office and open your .xlsx or .xlsm file to access your data.
  2. 2. Set a custom Print Area: Navigate to the Page Layout tab on the top ribbon, select your desired cell range, click the 'Print Area' button, and choose 'Set Print Area'.
  3. 3. Use Macros to enforce settings: Go to the Developer tab to access the VBA Editor, where you can paste your page setup locking scripts just like you would in Excel.
Fully compatible with Microsoft Excel (.xlsx and .xlsm) formatsSeamless VBA macro support for automating tasks and enforcing layout settingsIntuitive Page Layout tab for quick and precise print area configurationFree and lightweight alternative for powerful data analysis and reporting
QA img-9

Frequently Asked Questions

Why doesn't 'Protect Sheet' lock the print area?

Excel's standard worksheet protection allows you to disable formatting cells and editing formulas, but the Page Setup menu and Print Area configurations remain accessible by design. Automation via VBA is strictly required to lock these particular settings.

Can I lock paper size and orientation as well?

Yes. Within your VBA macro, you can add properties such as 'ActiveSheet.PageSetup.Orientation = xlLandscape' and 'ActiveSheet.PageSetup.PaperSize = xlPaperA4' to lock those specific page attributes.

What happens if a user disables macros upon opening the file?

If a user chooses to disable macros when opening the workbook, the VBA code that resets the print area will not execute. Consequently, they will be able to alter the print settings freely.

How do I remove the locked print area later?

To remove the lock, you must access the VBA Editor by pressing Alt + F11, unlock the project using your predefined password, and delete or comment out the PageSetup macro code from the ThisWorkbook module.