Lock Shapes in Excel and Word Using VBA and Document Protection
Question details
Prevent users from moving or editing shapes in Excel or Word, and limit shape selection where possible.

- 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.
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.
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.
In Excel, select the worksheet and open Home > Find & Select > Selection Pane. Note the name of the shape you want to lock.
Press Alt+F11, select the workbook in the editor, and choose Insert > Module.
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
Return to the target worksheet, open Developer > Macros, select LockShape, and click Run. Try moving or editing the shape to confirm the protection.

Restrict editing in Word to protect shapes
Use Word's read-only editing restriction when you need to prevent changes to a document and its shapes.
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.

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.




