How to start VBA-subroutine word document without ActiveX?

Rosenbohm, Mario 40 Reputation points
2025-08-14T06:36:09.04+00:00

Hello,

Until now, I have been starting my VBA subroutines in various Word (docm) files by clicking on an image (icon) element.

ActiveX is now disabled in Office 365.

How can I start the VBA subroutine by clicking on an image?

Best regards Mario

Microsoft 365 and Office | Word | For business | Windows
0 comments No comments
{count} votes

Answer accepted by question author
  1. Sting-Ng 5,155 Reputation points Microsoft External Staff Moderator
    2025-08-14T07:24:14.6166667+00:00

    Hi @Rosenbohm, Mario 

    Welcome to the Q&A Community 

    I’m here to assist your problem. 

    Base on your description, I recommended you: 

    1/ Enable Developer tab (if not already visible): 

    • Go to File > Options > Customize Ribbon
    • In the right pane, check the box for Developer
    • Click OK

    User's image

    2/ Insert a picture content control: 

    *Open your .docm document. 

    *Place your cursor where you want the clickable image: 

    • Go to the Developer tab > Controls group. 
    • Click the Picture Content Control button (it looks like a small picture frame icon). 
    • This inserts a placeholder control. Click inside it to browse and insert your desired image (e.g., your icon). The image will fill the control 

    3/ Configure the content control properties

    • Select the picture content control (click on it). 
    • In the Developer tab > Controls group, click Properties
    • In the dialog box:  
    • Set the Title to a unique name, such as "RunMySub" (this will be used in the VBA code to identify it). 
    • Optionally, check Content control cannot be deleted and Contents cannot be edited to prevent accidental changes. 
    • Click OK

     

    4/ Add the VBA Event handler: 

    • Press Alt + F11 to open the Visual Basic for Applications (VBA) editor. 
    • In the Project Explorer pane (on the left), expand your document (e.g., "ThisDocument" under the document name). 
    • Double-click ThisDocument to open its code module. 
    • Paste the following code into the module: 
    Private Sub Document_ContentControlOnEnter(ByVal ContentControl As ContentControl) 
        If ContentControl.Title = "RunMySub" Then 
            ' Call your existing subroutine here 
            Call YourSubroutineName 
        End If 
    End Sub  
    
    • Replace "RunMySub" with the title you set in Step 3. 
    • Replace YourSubroutineName with the actual name of your VBA subroutine (e.g., MyMacro). 
    • If your subroutine has parameters, include them in the Call statement as needed. 
    • Save the changes (ensure the document is saved as .docm to preserve macros). 

    5/ Test and Check

    • Return to the Word document. 
    • Click the image in the Content Control. 
    • The macro should execute immediately. 
    • Note: If the document has multiple controls, ensure titles are unique to avoid conflicts. Tabbing into the control will also trigger it, but for image-based "buttons," clicking is the primary interaction. 

    We appreciate your kind patience and understanding that sometimes the initial response may not immediately resolve the issue or there may be some misunderstandings about your scenario, but we would love to hear updates from you and find out further suggestions. 

    Thank you for your kindness and understanding. If you need anything else, please feel free to contact me.  


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment" 

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread. 

    User's image

    0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Jay Freedman 205.8K Reputation points Volunteer Moderator
    2025-08-14T16:18:24.0066667+00:00

    While the setup proposed by Sting-Ng will work, there is a much simpler answer: Replace the ActiveX control with a MacroButton field, described at https://support.microsoft.com/en-us/office/field-codes-macrobutton-field-d628b4d4-fb7d-4bbc-8a3b-fb8fe3f83be4 and at https://wordmvp.com/FAQs/TblsFldsFms/UsingMacroButton.htm.

    2 people found this answer helpful.

  2. Rosenbohm, Mario 40 Reputation points
    2025-08-14T11:13:44.1633333+00:00

    Hello Sting,

    ‘... without ActiveX’.

    How is the ActiveX Picture content control supposed to function in that case?

    ActiveX is disabled in the Trust Centre and cannot/may not be enabled.

    Best regards, Mario


  3. Rosenbohm, Mario 40 Reputation points
    2025-08-15T04:42:30.2566667+00:00

    Hello,

    until yesterday, when I tried to use ‘Picture Content Control’, I got the message ‘This control is not available’ and could only insert it after activating ActiveX support.

    Since this morning, I have been able to insert the Picture control ‘normally’ with ActiveX disabled. Why is it working now? Regardless, it is now functional.

    Thank you very much, now I can ‘tinker’ with VBA macros even without ActiveX.

    Best regards, Mario


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.