Remove a Persistent ActiveX Command Button from a Word Document
Question details
Remove an ActiveX command button that remains in a macro-enabled Word document after its first page is deleted.

- 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.
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.
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.
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.
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.
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.
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.
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.

Delete the ActiveX button without replacing its code
Use this approach if the button's Click event is no longer needed.
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.

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.




