XML not fetching VBA code?


New Member
Apr 17, 2015

I have to plead ignorance.... I really need some help with this as I am new to combining XML/VBA!

Please skim over the following HTML/VBA code I have in my Excel project:

<customUI ******="Ribbon******" xmlns="http://schemas.microsoft.com/office/2006/01/customui">
	<!-- <ribbon startFromScratch="true" >  !!!! temporarilly commented !!!! -->
			<tab id="customTab" label="CONTROLS" insertAfterMso="TabHome">
				<group id="customGroup5" label="Menu tab options">
					<button id="customButton9" label="Menu Tab Options" size="large" onAction="DisplayDevTools" imageMso="DefinePrintStyles" />

			<tab idMso="TabDevelopper" getVisible="RibbonX.GetVisible"  />

And in RibbonX VBA module I have the following:

Option Explicit

Dim Rib As IRibbonUI
Public myId As String
'Public myOnOff_Flag As Integer

''Callback for customUI.******
Sub Ribbon******(ribbon As IRibbonUI)
    Set Rib = ribbon
End Sub

Sub GetVisible(control As IRibbonControl, ByRef visible)
    If myId = "show" Then               ' <<<<<< break point here, but program never gets here ???
        visible = True
        If control.Id Like myId Then
            visible = True
            visible = False
        End If
    End If
End Sub

Sub DisplayDevTools(control As IRibbonControl)
myId = control.Id
End Sub

Above, customButton9 is a button on the ribbon. When I click on this button, I successfully run the DisplayDevTools() residing in the RibbonX VBA module.

First I am a little confused as to what Rib.Invalidate really does?


After the Rib.Invalidate statement, the HTML code should get to this line:

<tab idMso="TabDevelopper" getVisible="RibbonX.GetVisible" />

which should fetch the GetVisible() function ...right? But it never does???

From what I could understand from Rob the bruin's examples, is that the Rib.Invalidate statement should refresh the ribbon and in turn should call the GetVisible()... and its not happening???

Why is it that in his examples shown here:


which show this principle and it works?? What am I doing wrong in my example above??

Sincere thanks in advance to all !

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
In your XML you have:
but it should be:
Upvote 0
Hi Rory,

That's a nice catch! I corrected it, but still doesn't work.....

Its like as if the getVisible() is never fetched from the XML code :eek:

I am relatively new to this forum and I don't see how to attach a workbook showing the issue???

How do we add an attachment here?

I sincerely thank you in advance !

Upvote 0
Ok now it works!

I realized that we have to re-start excel, to set Rib!!!!

Also this line threw me off:

       If control.Id Like myId Then

I don't know why Ron de Bruin used it like this...??

I did this instead and everything worked fine

If control.Id = "TabDeveloper" And myOnOff_Flag <> False Then

I have a last question about XML???

what is the difference between id and idMso in the following two lines below:
<tab id="customTab" label="CONTROLS" insertAfterMso="TabHome">

<tab idMso="TabDeveloper" getVisible="RibbonX.GetVisible"  />
Thanks all for your help!
Last edited by a moderator:
Upvote 0
id is for custom objects, whereas idMso is for built-in ones. (there's also idQ for shared custom objects)
Upvote 0

Forum statistics

Latest member

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back