VBA & Macro Problems

Lock Shapes in Excel and Word Using VBA and Document Protection

Natalie TaylorNatalie Taylor Nov 18, 2026 870 views

Question details

Prevent users from moving or editing shapes in Excel or Word, and limit shape selection where possible.

How to Lock Shapes in Excel and Word
Product
Microsoft Excel and Microsoft Word
Device & OS
not provided
Scenario
The user wants to protect shapes without PowerPoint's visual lock feature, preferably using VBA.
Observed behavior
The user needs a way to protect shapes from changes and selection in Excel or Word.
Before you start

Identify the shape and its name in Excel's Selection Pane before writing the macro. To run VBA, use a desktop version of Excel that supports macros and save the workbook as an .xlsm file.

Solution 1Recommended

Lock an Excel shape with VBA and worksheet protection

Use this method to protect a specific Excel shape from moving or editing.

A shape's Locked property only takes effect when the worksheet is protected with drawing objects protected. Selection behavior can vary, so test it in your version of Excel.

1
Find the shape name

In Excel, select the worksheet and open Home > Find & Select > Selection Pane. Note the name of the shape you want to lock.

2
Open the VBA editor

Press Alt+F11, select the workbook in the editor, and choose Insert > Module.

3
Add the macro

Paste this code into the module, replacing Shape 1 with the name from the Selection Pane: Sub LockShape() ActiveSheet.Shapes("Shape 1").Locked = True ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True End Sub

4
Run and test

Return to the target worksheet, open Developer > Macros, select LockShape, and click Run. Try moving or editing the shape to confirm the protection.

Lock an Excel shape with VBA and worksheet protection
Protection scope: The sample protects the active worksheet and its contents as well as drawing objects. Unprotect the sheet before changing protected content. Worksheet protection is not a substitute for file encryption or a guarantee against deliberate tampering.
Free Microsoft Office alternative

Work with Office documents and shapes in WPS Office

WPS Office is a free, lightweight Office alternative with a familiar interface and support for common Microsoft Office formats, making it easier to move between document workflows. It does not fix Microsoft Excel or Word's shape-locking behavior; check VBA and protection compatibility before relying on an existing macro.

Open and edit spreadsheets and documents containing shapesCompatible with common Microsoft Office formats, including XLSX and DOCXFamiliar spreadsheet and document interfaces support an easier transitionFree and lightweight for everyday Office tasks
microsoft office alternative - wps office

Frequently Asked Questions

Why can I still move a shape after setting Locked to True in Excel?

The Locked property takes effect only when the worksheet is protected with drawing objects protected. Run the protection command in the macro or use Review > Protect Sheet and ensure object editing is not permitted.

Can I lock an Excel shape without VBA?

Yes. Select the shape, open its Size and Properties settings, and confirm that Locked is selected. Then use Review > Protect Sheet and protect drawing objects.

Will Word's read-only restriction stop users from selecting a shape?

Not necessarily. Review > Restrict Editing can prevent changes, but it does not guarantee that a shape cannot be selected.

How do I edit the Excel shape again?

Choose Review > Unprotect Sheet and provide the password if one was set. You can then move or edit the shape and protect the sheet again afterward.