How to Lock Print Area and Print Settings in Excel
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.

- 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.
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.
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.
Launch your Excel workbook and press 'Alt + F11' on your keyboard to open the Visual Basic for Applications (VBA) editor.
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.
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.
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.
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.
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. Open your file in WPS Spreadsheet: Launch WPS Office and open your .xlsx or .xlsm file to access your data.
- 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. 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.

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.




