How to Protect VBA Code in a Protected WPS Office Spreadsheet
Question details
The user wants to prevent other users from opening or editing VBA macro code after protecting worksheet contents in WPS Office Spreadsheets.

- Product
- WPS Office Spreadsheets
- Device & OS
- not provided
- Scenario
- The user has a workbook with protected worksheet contents and needs to restrict access to the VBA project code.
- Observed behavior
- The VBA code can still be opened or edited until the VBA project is locked for viewing with a password.
Open the workbook in WPS Office Spreadsheets and make sure the Developer tab and Visual Basic Editor are available. Choose a strong VBA project password you can remember, because WPS Office cannot recover it if it is lost.
Lock the VBA Project for Viewing in WPS Office Spreadsheets
Use this method to keep macro code hidden and stop users from editing it in the Visual Basic Editor after worksheet contents are protected.
Protecting a worksheet and locking a VBA project are separate protections. Use this method after you have protected worksheet contents so users cannot edit cell data and cannot open or change the macro code.
In WPS Office Spreadsheets, click the Developer tab, then click Visual Basic Editor. You can also press Alt+F11 if the shortcut is available.
In the Project Explorer, select your workbook’s VBAProject, then go to Tools > VBAProject Properties.
Select the Protection tab, check Lock project for viewing, enter the password twice, and click OK.
Save the workbook as a macro-enabled file, close WPS Office, and reopen the file. The VBA project now asks for the password before anyone can view or edit the code.

Protect VBA Code in WPS Office Spreadsheets
WPS Office Spreadsheets provides built-in VBA project protection: open the Visual Basic Editor, lock the project for viewing, set a password, and reopen the workbook to require it before viewing or editing macros.
- 1. Enable the Developer tab: In WPS Spreadsheets, go to File > Options > Customize Ribbon and enable the Developer tab if it is not already visible.
- 2. Open the Visual Basic Editor: Click Developer > Visual Basic Editor or press Alt+F11.
- 3. Lock the VBA project: Select Tools > VBAProject Properties, go to the Protection tab, check Lock project for viewing, and set a password.
- 4. Save and reopen the workbook: Save as a macro-enabled workbook, close WPS Office, and reopen the file to activate the password protection.

Frequently Asked Questions
Does protecting worksheet contents also protect VBA code?
No. Worksheet protection only restricts cell and sheet changes. You must open the Visual Basic Editor and lock the VBAProject in Tools > VBAProject Properties to protect the macro code.
Where do I set the VBA project password in WPS Office?
Open the Developer tab in WPS Office Spreadsheets, click Visual Basic Editor, then go to Tools > VBAProject Properties > Protection and check Lock project for viewing.
When does the VBA project password take effect?
After you save the workbook, close WPS Office, and reopen the file. The password prompt will not appear until the project is reopened.
Can the VBA project password be recovered if forgotten?
WPS Office does not provide a built-in VBA password recovery option. Keep the password in a safe place. Third-party recovery tools may exist but are not supported.
Is VBA project password protection absolutely secure?
No. It is a deterrent that prevents casual viewing and editing, but specialized methods can bypass VBA project passwords. For high-security code, consider additional protection approaches.




