VBA & Macro Problems

Remove a Persistent ActiveX Command Button from a Word Document

Rana GarciaRana Garcia Nov 25, 2026 868 views

Question details

Remove an ActiveX command button that remains in a macro-enabled Word document after its first page is deleted.

Remove a Persistent ActiveX Command Button from a Word Document
Product
Microsoft Word
Device & OS
not provided
Scenario
The user deleted the first page of a macro-enabled document and wants to remove its command button while retaining any needed initialization code.
Observed behavior
The button reappears after Design Mode is turned off and remains listed as an object.
Before you start

In Word, enable the Developer tab through File > Options > Customize Ribbon if it is hidden. Open the Visual Basic editor and check whether the button's Click event contains code you still need.

Solution 1Recommended

Remove the button and move its initialization code to an AutoNew macro

Use a macro-enabled template to run the button's initialization code when you create a new document, without retaining the button.

AutoNew runs when a new document is created from the template; it does not run merely because an existing document is opened. Code that refers to the button or its properties may need to be rewritten before it can run independently.

1
Find the button code

Open the document, select Developer > Design Mode, then right-click the button and choose View Code. Copy the commands inside its Click event, excluding the event's Sub and End Sub lines.

2
Remove the control

Return to the document, keep Developer > Design Mode enabled, select the button's border, and press Delete. If it is in a header or footer, double-click that area first, then select and delete the control.

3
Save a template

Choose File > Save As and select Word Macro-Enabled Template (*.dotm) as the file type. Save the template in a location where you can find it when creating a document.

4
Create the AutoNew macro

Open Developer > Visual Basic, select the template project, and choose Insert > Module. Add a procedure named Sub AutoNew(), paste the copied commands inside it, and finish with End Sub. Adjust any references that depend on the deleted button.

5
Create and test a document

Save and close the template, then use File > New to create a document from it. Allow macros only if you trust the template, and verify that the initialization runs and the button is absent.

Remove the button and move its initialization code to an AutoNew macro
Existing documents: Moving the code to a template does not automatically remove the button from documents already created. Delete the control in each affected document as needed.
Free Microsoft Office alternative

Edit Word documents with WPS Writer

WPS Office is a free, lightweight alternative with a familiar interface for opening and editing Word documents. Its format compatibility makes it easier to move everyday documents between Office suites; use Microsoft Word for this ActiveX and VBA task.

Open and edit common Microsoft Word formats such as DOCX and DOCWork with document text and layouts in a familiar interfaceUse a free, lightweight office suite for everyday documentsMove compatible documents between Microsoft Office and WPS Office
microsoft office alternative - wps office

Frequently Asked Questions

Why is the button still visible after I delete the first page?

Deleting page content does not necessarily remove a control stored elsewhere in the document. Turn on Developer > Design Mode and check the button's location, including any header or footer.

Where should I put the AutoNew macro?

In Developer > Visual Basic, select the macro-enabled template project and choose Insert > Module. Place Sub AutoNew() in that module and save the template as a .dotm file.

Will AutoNew run when I open an existing document?

No. AutoNew is intended to run when a new document is created from the template, provided macros are allowed.

Can I paste the entire Click event into AutoNew unchanged?

Copy the commands inside the Click event, not its event declaration. Check and revise references to the button or its properties, because the control will no longer be present.