How to Prevent Users from Printing Excel File
Contents
[
Hide
]
Possible Usage Scenarios
In our daily work, there may be some important information in the excel file, in order to protect the internal data outspread, the company will not allow us to print them. This document will tell you how to prevent others from printing Excel files.
How to Prevent Users from Printing File in MS-Excel
You can apply the following VBA code to protect your specific file to be printed.
- Open your workbook which you don’t allow others to print.
- Select “Developer” tab tab in the Excel ribbon and Click on the “View Code” button in the “Controls” section. Alternatively, you can hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.
- And then in the left Project Explorer, double click ThisWorkbook to open the module, and add some vba codes.
- Then save and close this code, and go to back the workbook, and now when you print the sample file, they will not allowed to be printed and you will get the following warning box:
How to Prevent Users from Printing Excel File using Aspose.Cells for .NET
The following sample code illustrates how to prevent users from printing excel file:
- Load the sample file.
- Get the VbaModuleCollection object from VbaProject property of Workbook.
- Get VbaModule object via “ThisWorkbook” name.
- Set the codes property of VbaModule.
- Save the sample file to xlsm format.