Seeking Help with Global Template (.dotm) – Ribbon Buttons Fail with Error 450

yanlok1345
2StarLounger
Posts: 104
Joined: 18 Oct 2023, 14:48

Seeking Help with Global Template (.dotm) – Ribbon Buttons Fail with Error 450

Post by yanlok1345 »

Hi VBA experts,

I’m struggling to create a functional global template (.dotm) for Word’s STARTUP folder. Followed guides meticulously, but macros fail or buttons don’t appear.

My Steps:
1️⃣ Created a .docx → saved as .dotm.
2️⃣ Added VBA modules with subs like:

Code: Select all

Sub Apple(Optional control As IRibbonControl)  
    [code]  
End Sub
3️⃣ Used Office RibbonX Editor to add Custom UI (Office 2010+).
4️⃣ XML example:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
  <ribbon>
    <tabs>
      <tab id="Apple" label="Apple">
        <group id="Apple" label="Apple">
          <button id="Apple1" label="Apple" size="large" onAction="Apple" imageMso="HappyFace"/>  
        </group> 
      </tab>
    </tabs>
  </ribbon> 
</customUI>
5️⃣ Saved & placed in:

Code: Select all

C:\Users\[user]\AppData\Roaming\Microsoft\Word\STARTUP
Issues:
❌ Buttons sometimes don’t appear.
❌ When they do, clicking triggers Error 450 (wrong args/not found).

Questions:
Are my Subs’ signatures correct for Ribbon callbacks?
Does the XML need strict namespace/attribute rules?
Any hidden steps for global templates?

Tried:
• Trust Center settings (enable macros/trust locations).
• ThisDocument module vs. standard modules.
• Renaming/rebooting.

Here's the .dotm i created, but it doesn't work. There is no button shown on the ribbon:
Doc1.dotm
Any guidance appreciated! 🙏
You do not have the required permissions to view the files attached to this post.
Last edited by yanlok1345 on 10 Apr 2025, 01:25, edited 1 time in total.

snb
5StarLounger
Posts: 730
Joined: 14 Nov 2012, 16:06

Re: Seeking Help with Global Template (.dotm) – Ribbon Buttons Fail with Error 450

Post by snb »

Why don't you upload your Word template ?

Delete:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
Delete "optional' in

Code: Select all

Sub Apple(Optional control As IRibbonControl)  
    [code]  
End Sub

User avatar
Charles Kenyon
5StarLounger
Posts: 684
Joined: 10 Jan 2016, 15:56
Location: Sun Prairie, Wisconsin

Re: Seeking Help with Global Template (.dotm) – Ribbon Buttons Fail with Error 450

Post by Charles Kenyon »

Questions:
Are my Subs’ signatures correct for Ribbon callbacks?
Does the XML need strict namespace/attribute rules?
Any hidden steps for global templates?
This is not a simple process. XML is case-sensitive, unlike vba.
I've been using global templates with ribbon modifications for more than 15 years.
It has been a while since I've done one, though.
Start with Greg's page and some simple steps.
Add one thing/process at a time, get it working, and progress to the next. When you try to do it all at once, there are too many things that could be causing problems.

You probably want to first test as a document template rather than global template to simplify debugging. Otherwise, to debug, you will need to unload the template and open it directly.

References: SNB suggested attaching your .dotm template. You could put it in a zip folder if it won't upload directly.

Which tool are you using to write the XML? I've used Office RibbonX Editor.

yanlok1345
2StarLounger
Posts: 104
Joined: 18 Oct 2023, 14:48

Re: Seeking Help with Global Template (.dotm) – Ribbon Buttons Fail with Error 450

Post by yanlok1345 »

snb wrote:
09 Apr 2025, 08:03
Why don't you upload your Word template ?

Delete:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
Delete "optional' in

Code: Select all

Sub Apple(Optional control As IRibbonControl)  
    [code]  
End Sub
I’ve just uploaded the file I created, which follows all your suggestion above but in vain. Could you please check if I missed anything that might be causing it not to work?

yanlok1345
2StarLounger
Posts: 104
Joined: 18 Oct 2023, 14:48

Re: Seeking Help with Global Template (.dotm) – Ribbon Buttons Fail with Error 450

Post by yanlok1345 »

Charles Kenyon wrote:
09 Apr 2025, 19:12
Questions:
Are my Subs’ signatures correct for Ribbon callbacks?
Does the XML need strict namespace/attribute rules?
Any hidden steps for global templates?
This is not a simple process. XML is case-sensitive, unlike vba.
I've been using global templates with ribbon modifications for more than 15 years.
It has been a while since I've done one, though.
Start with Greg's page and some simple steps.
Add one thing/process at a time, get it working, and progress to the next. When you try to do it all at once, there are too many things that could be causing problems.

You probably want to first test as a document template rather than global template to simplify debugging. Otherwise, to debug, you will need to unload the template and open it directly.

References: SNB suggested attaching your .dotm template. You could put it in a zip folder if it won't upload directly.

Which tool are you using to write the XML? I've used Office RibbonX Editor.
Thank you for your response. I had already started from Greg's website many times but in vain.

As you can see, the steps in my thread are already extremely simple, yet the issue persists.

I’ve just uploaded the .dotm file to my thread for reference. For clarity, I used Office Ribbon X Editor (as mentioned in my original post).

snb
5StarLounger
Posts: 730
Joined: 14 Nov 2012, 16:06

Re: Seeking Help with Global Template (.dotm) – Ribbon Buttons Fail with Error 450

Post by snb »

See the attachment

NB: ID's should be unique to identify them.
You do not have the required permissions to view the files attached to this post.

yanlok1345
2StarLounger
Posts: 104
Joined: 18 Oct 2023, 14:48

Re: Seeking Help with Global Template (.dotm) – Ribbon Buttons Fail with Error 450

Post by yanlok1345 »

snb wrote:
10 Apr 2025, 09:07
See the attachment

NB: ID's should be unique to identify them.
Wow! Thank you so much for your help. May I confirm if the steps align with what I’ve written in the main thread?

snb
5StarLounger
Posts: 730
Joined: 14 Nov 2012, 16:06

Re: Seeking Help with Global Template (.dotm) – Ribbon Buttons Fail with Error 450

Post by snb »

My Steps:
1️⃣ Created a .docx → saved as .dotm.
2️⃣ add a macro in the macrocodule of thisdocument

Code: Select all

Sub M_Apple(Optional control As IRibbonControl)  
    msgBox "snb"
End Sub
3. close the file
4. Use Office RibbonX Editor to add Custom UI (Office 2010+).
5. Open the .dotm file
4️⃣XML example:

Code: Select all

<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
  <ribbon>
    <tabs>
      <tab id="T_Apple" label="Apple">
        <group id="G_Apple" label="Apple">
          <button id="B_Apple" label="Apple" size="large" onAction="thisdocument.M_Apple" imageMso="HappyFace"/>  
        </group> 
      </tab>
    </tabs>
  </ribbon> 
</customUI>
5️⃣Save it anywhere
6. In the developer tab add the saved .dotm file as an addin

yanlok1345
2StarLounger
Posts: 104
Joined: 18 Oct 2023, 14:48

Re: Seeking Help with Global Template (.dotm) – Ribbon Buttons Fail with Error 450

Post by yanlok1345 »

snb wrote:
10 Apr 2025, 15:56
My Steps:
1️⃣ Created a .docx → saved as .dotm.
2️⃣ add a macro in the macrocodule of thisdocument

Code: Select all

Sub M_Apple(Optional control As IRibbonControl)  
    msgBox "snb"
End Sub
3. close the file
4. Use Office RibbonX Editor to add Custom UI (Office 2010+).
5. Open the .dotm file
4️⃣XML example:

Code: Select all

<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
  <ribbon>
    <tabs>
      <tab id="T_Apple" label="Apple">
        <group id="G_Apple" label="Apple">
          <button id="B_Apple" label="Apple" size="large" onAction="thisdocument.M_Apple" imageMso="HappyFace"/>  
        </group> 
      </tab>
    </tabs>
  </ribbon> 
</customUI>
5️⃣Save it anywhere
6. In the developer tab add the saved .dotm file as an addin
Many thanks for your detailed explanation! :thankyou:

User avatar
Charles Kenyon
5StarLounger
Posts: 684
Joined: 10 Jan 2016, 15:56
Location: Sun Prairie, Wisconsin

Re: Seeking Help with Global Template (.dotm) – Ribbon Buttons Fail with Error 450

Post by Charles Kenyon »

@snb
Well done!