Document Editing Problems

Change Shape Colors in a Protected Word Flowchart

Muhammad TalhaMuhammad Talha Nov 20, 2026 868 views

Question details

Allow users to change flowchart shape colors without allowing unrestricted text formatting.

Change Shape Colors in a Protected Word Flowchart
Product
Microsoft Word
Device & OS
not provided
Scenario
A protected flowchart has selected text regions that users can edit, but shape color changes are also needed.
Observed behavior
The current protection prevents shape color changes, while allowing shape formatting also permits unwanted text edits.
Before you start

Use desktop Word with permission to run VBA macros, and confirm that the document uses read-only editing restrictions. Test on a copy, and obtain the protection password if one is set.

Solution 1Recommended

Use a VBA macro to change a shape’s color and restore protection

Use this approach when you can run a trusted macro and know the document’s protection password, if applicable.

The macro temporarily removes read-only protection, changes the selected shape’s fill to a preset color, and then reapplies protection. It attempts to restore protection if an error occurs, but cannot guarantee restoration after an interruption.

The protection password is requested each time and is not stored in the macro. Word’s input box displays the password as you type.

1
Save a macro-enabled test copy

In Word, select File > Save As and choose Word Macro-Enabled Document (*.docm). Open Review > Restrict Editing and confirm that the document uses the read-only restriction.

2
Add the macro

Press Alt+F11 to open the VBA editor, select the test document’s project, and choose Insert > Module. Paste this code: Sub ChangeProtectedShapeColor() Dim shp As Shape Dim pwd As String Dim unlocked As Boolean Dim problem As String On Error GoTo Failed If ActiveDocument.ProtectionType <> wdAllowOnlyReading Then MsgBox "This macro requires read-only document protection." Exit Sub End If If Selection.ShapeRange.Count <> 1 Then MsgBox "Select one shape and try again." Exit Sub End If Set shp = Selection.ShapeRange(1) pwd = InputBox("Enter the protection password, or leave blank if none:") ActiveDocument.Unprotect Password:=pwd unlocked = True shp.Fill.ForeColor.RGB = RGB(25, 120, 200) GoTo RestoreProtection Failed: problem = Err.Description Err.Clear RestoreProtection: If unlocked Then On Error Resume Next ActiveDocument.Protect Type:=wdAllowOnlyReading, NoReset:=True, Password:=pwd If Err.Number <> 0 Then MsgBox "Protection could not be restored. Use Review > Restrict Editing to protect the document manually." Exit Sub End If On Error GoTo 0 End If If problem <> "" Then MsgBox "The color change did not complete: " & problem End Sub

3
Choose the color

In the VBA editor, replace RGB(25, 120, 200) with the desired red, green, and blue values from 0 to 255. To change the outline instead, replace shp.Fill.ForeColor.RGB with shp.Line.ForeColor.RGB.

4
Add a run button

In Word, open File > Options > Quick Access Toolbar, choose Macros from the command list, and add ChangeProtectedShapeColor. Alternatively, assign it a shortcut through File > Options > Customize Ribbon > Keyboard shortcuts: Customize.

5
Test the protected flowchart

Select one shape, run the macro from the Quick Access Toolbar or shortcut, and enter the password if prompted. Check Review > Restrict Editing and test both the intended editable text regions and restricted text after the macro runs.

Use a VBA macro to change a shape’s color and restore protection
Protection limitations: The macro briefly unprotects the whole document and requires the protection password when one is set. Verify that your editing exceptions still work after reprotection; if protection is not restored, apply it manually through Review > Restrict Editing.
Free Microsoft Office alternative

Edit Word Flowchart Documents with WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for working with Office documents. Open compatible Word files to continue editing flowchart content as you move between suites; it does not fix Word’s protection settings or guarantee VBA macro compatibility.

Work with flowchart shapes in a familiar document-editing interfaceOpen and edit compatible Microsoft Word DOC and DOCX filesUse a free, lightweight Office alternativeMove between Office suites with familiar document tools
microsoft office alternative - wps office

Frequently Asked Questions

Can I run this macro in Word for the web?

No. Open the macro-enabled document in desktop Word to create and run the VBA macro.

Do I need the document protection password?

Yes, if a password was set. The macro must unprotect the document before changing the shape and uses the same password to protect it again.

How do I change the shape outline instead of the fill?

In the VBA editor, replace shp.Fill.ForeColor.RGB with shp.Line.ForeColor.RGB, then set the RGB values to the desired outline color.

What should I do if the document is left unprotected?

Open Review > Restrict Editing, select the appropriate editing restriction, and start enforcement again. Then verify the editable regions and password settings.

Will the macro preserve every editing exception?

Do not assume it will. After running the macro on a test copy, check Review > Restrict Editing and test the regions that should remain editable or restricted.