VBA & Macro Problems

How to Protect VBA Code in a Protected WPS Office Spreadsheet

Kushani NimanthikaKushani Nimanthika Nov 13, 2026 881 views

Question details

The user wants to prevent other users from opening or editing VBA macro code after protecting worksheet contents in WPS Office Spreadsheets.

How to Protect VBA Code in a Protected WPS Office Spreadsheet
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.
Before you start

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.

Solution 1Recommended

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.

1
Open the Visual Basic Editor

In WPS Office Spreadsheets, click the Developer tab, then click Visual Basic Editor. You can also press Alt+F11 if the shortcut is available.

2
Open VBAProject Properties

In the Project Explorer, select your workbook’s VBAProject, then go to Tools > VBAProject Properties.

3
Set the protection password

Select the Protection tab, check Lock project for viewing, enter the password twice, and click OK.

4
Save and reopen the workbook

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.

Lock the VBA Project for Viewing in WPS Office Spreadsheets
Not completely tamper-proof: This VBA project password is not completely tamper-proof. Specialized methods can bypass it, so treat it as a deterrent rather than strong encryption.
WPS Office Spreadsheets

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. 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. 2. Open the Visual Basic Editor: Click Developer > Visual Basic Editor or press Alt+F11.
  3. 3. Lock the VBA project: Select Tools > VBAProject Properties, go to the Protection tab, check Lock project for viewing, and set a password.
  4. 4. Save and reopen the workbook: Save as a macro-enabled workbook, close WPS Office, and reopen the file to activate the password protection.
Blocks casual viewing and editing of VBA codeSupports Excel .xlsm macro-enabled workbook formatFree and lightweight compared with Microsoft ExcelFamiliar ribbon interface and Visual Basic Editor workflow
microsoft office alternative - wps office

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.