XML not fetching VBA code?

Shinning

New Member
Joined
Apr 17, 2015
Messages
17
Hello,

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:

PHP:
<customUI ******="Ribbon******" xmlns="http://schemas.microsoft.com/office/2006/01/customui">
      <ribbon>
	<!-- <ribbon startFromScratch="true" >  !!!! temporarilly commented !!!! -->
		<tabs>
			<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" />
				</group>
			</tab>

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

And in RibbonX VBA module I have the following:


Code:
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
    Else
        If control.Id Like myId Then
            visible = True
        Else
            visible = False
        End If
    End If
End Sub


Sub DisplayDevTools(control As IRibbonControl)
myId = control.Id
Rib.Invalidate                    
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?

Next:

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:

http://www.excelforum.com/excel-gene...e-explain.html

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

Sincere thanks in advance to all !
S
 

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:
HTML:
idMso="TabDevelopper"
but it should be:
HTML:
idMso="TabDeveloper"
 
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 !

S
 
Upvote 0
Ok now it works!

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

Also this line threw me off:


Code:
       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

Code:
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:
HTML:
<tab id="customTab" label="CONTROLS" insertAfterMso="TabHome">

<tab idMso="TabDeveloper" getVisible="RibbonX.GetVisible"  />
Thanks all for your help!
s
 
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

Threads
1,203,486
Messages
6,055,702
Members
444,809
Latest member
mwh85

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
Back
Top