PDA

View Full Version : [SOLVED:] Custom Ribbon Startup - Conflict



dj44
03-22-2017, 08:20 AM
Hi folks,

I am trying to make a ribbon

I made 3 of them.
I put them in startup but then they stop working.

If I put only 1 ribbon as a dotm in start up it works and the macros are picked up.
So I have this as example


Textmacros.dotm
Tablemacros.dotm

Etc

They use the exact code as below

When I only have 1 ribbon it works perfectly the minute I put another dotm then I have blank macros

Is it because of a ribbon conflict?
They use the same xml code





<!-- This code was created by TheSpreadsheetGuru.com (owned by Guru Solutions, LLC)-->
<!-- All rights are reserved and this code may not be resold (copyright 2015)-->

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" >

<ribbon>
<tabs>
<tab id="CustomTab" getLabel="GetLabel" insertAfterMso= "TabDeveloper">
<group id="SpaceGroup0" getVisible = "GetVisible">
<button id="SpaceButton0" getImage="GetImage" getVisible = "GetVisible"/>
</group>
<group id="GroupA" getVisible = "GetVisible" getLabel="GetLabel">
<button id="aButton01" getLabel="GetLabel" onAction="RunMacro" getImage="GetImage" getScreentip = "GetScreentip" getVisible = "GetVisible"/>
<menuSeparator id="ms1"/>
<button id="aButton02" getLabel="GetLabel" onAction="RunMacro" getImage="GetImage" getScreentip = "GetScreentip" getVisible = "GetVisible"/>
</menu>
</group>


Sub GetLabel(ByVal control As IRibbonControl, ByRef Labeling)
'PURPOSE: Determine the text to go along with your Tab, Groups, and Buttons

Select Case control.ID


Case "CustomTab": Labeling = "Test"
Case "GroupA": Labeling = "1"

Case "aButton01": Labeling = "hello "

End Select


what could be the problem?

gmaxey
03-23-2017, 03:21 PM
What to you mean by I have blank macros?

It appears that you have two templates loaded with the same procedure name. The callbacks don't know where to go to run

dj44
03-23-2017, 05:23 PM
Hello Greg,

Nice to see you,

Well all the ribbons use the exact same code - but they are in different templates.
but now i see that there is a problem - the buttons dont have any text on them as i labeled in the module -

Is this the idea about the call back.

Template 1 Call Backs

<button id="aButton02" getLabel="GetLabelTemplate1" onAction="RunMacroA" />

Sub GetLabelTemplate1(ByVal control As IRibbonControl, ByRef Labeling)

Template 2 Call Backs

<button id="aButton02" getLabel="GetLabelTemplate2" onAction="RunMacroB"/>

Sub GetLabelTemplate2(ByVal control As IRibbonControl, ByRef Labeling)


I made a nice ribbon that took me months on how to understand it - and now I will have to somehow fix it as I never knew about this call back thing

ok so i need to label the callbacks with a unique id

Paul_Hossler
03-23-2017, 06:59 PM
I think it's be a LOT easier to see what's going on if you posted your 2 or 3 DOTM's

gmaxey
03-23-2017, 07:54 PM
I would start by naming the callback modules something like Temp1RibCon, Temp2RibCon etc. then changing the RibbonX e.g.<
getLabel="Temp1RibCon.GetLabel"

dj44
03-23-2017, 08:24 PM
Hi Paul & Greg,

it wouldnt allow me to upload the template.

I am using one Template1.dotm

then I duplicate Template 1 to make another Ribbon and call it
Tablemacros.dotm
textmacros.dotm
etc


So when the templates load they all have the same tab name and its blank

so something about the call backs i need to rename

i broke something in the xml and it completly shut down

oh dear I gues me and ribbons are not cut out to be - i was very happy to make this but its been a colosolal failure




<!-- This code was created by TheSpreadsheetGuru.com (owned by Guru Solutions, LLC)-->
<!-- All rights are reserved and this code may not be resold (copyright 2015)-->

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" >

<ribbon>
<tabs>
<tab id="CustomTab" getLabel="GetLabel" insertAfterMso= "TabDeveloper">

<group id="SpaceGroup0" getVisible = "GetVisible">
<button id="SpaceButton0" getImage="GetImage" getVisible = "GetVisible"/>
</group>
<group id="GroupA" getVisible = "GetVisible" getLabel="GetLabel">
<menu id="DDM1" getLabel="GetLabel" size="large" imageMso="TextAlignGallery" itemSize="large">
<button id="aButton01" getLabel="GetLabel" onAction="RunMacro" getImage="GetImage" getScreentip = "GetScreentip" getVisible = "GetVisible"/>
<menuSeparator id="ms1"/>
<button id="aButton02" getLabel="GetLabel" onAction="RunMacro" getImage="GetImage" getScreentip = "GetScreentip" getVisible = "GetVisible"/>
<menuSeparator id="ms2"/>
<button id="aButton03" getLabel="GetLabel" onAction="RunMacro" getImage="GetImage" getScreentip = "GetScreentip" getVisible = "GetVisible"/>
<menuSeparator id="ms3"/>
<button id="aButton04" getLabel="GetLabel" onAction="RunMacro" getImage="GetImage" getScreentip = "GetScreentip" getVisible = "GetVisible"/>
<menuSeparator id="ms4"/>
<button id="aButton05" getLabel="GetLabel" onAction="RunMacro" getImage="GetImage" getScreentip = "GetScreentip" getVisible = "GetVisible"/>
<menuSeparator id="ms5"/>
<button id="aButton06" getLabel="GetLabel" onAction="RunMacro" getImage="GetImage" getScreentip = "GetScreentip" getVisible = "GetVisible"/>
<menuSeparator id="ms6"/>
<button id="aButton07" getLabel="GetLabel" onAction="RunMacro" getImage="GetImage" getScreentip = "GetScreentip" getVisible = "GetVisible"/>
<menuSeparator id="ms7"/>
<button id="aButton08" getLabel="GetLabel" onAction="RunMacro" getImage="GetImage" getScreentip = "GetScreentip" getVisible = "GetVisible"/>
<menuSeparator id="ms8"/>
<button id="aButton09" getLabel="GetLabel" onAction="RunMacro" getImage="GetImage" getScreentip = "GetScreentip" getVisible = "GetVisible"/>
<menuSeparator id="ms9"/>
<button id="aButton10" getLabel="GetLabel" onAction="RunMacro" getImage="GetImage" getScreentip = "GetScreentip" getVisible = "GetVisible"/>
<menuSeparator id="ms10"/>

</menu>
</group>

</tab>
</tabs>
</ribbon>
</customUI>


Sub GetLabel(ByVal control As IRibbonControl, ByRef Labeling)
'PURPOSE: Determine the text to go along with your Tab, Groups, and Buttons

Select Case control.ID
Case "CustomTab": Labeling = "Hello From Ribbon"
Case "GroupA": Labeling = "1"
Case "DDM1": Labeling = "Group 1"

Case "aButton01": Labeling = " Run Macro 1 "
Case "aButton02": Labeling = " Run Macro 2"
Case "aButton03": Labeling = "Run Macro 3 "
Case "aButton04": Labeling = "Run Macro 4"
Case "aButton05": Labeling = "Run Macro 5"

Case "aButton06": Labeling = " "
Case "aButton07": Labeling = " "
Case "aButton08": Labeling = " "
Case "aButton09": Labeling = " "
Case "aButton10": Labeling = " "

End Select
End Sub


Sub RunMacro(control As IRibbonControl)
'PURPOSE: Tell each button which macro subroutine to run when clicked

Select Case control.ID


'--- GROUP 1

Case "aButton01": Application.Run "Macro1"
Case "aButton02": Application.Run "Macro2"
Case "aButton03": Application.Run "Macro3"
Case "aButton04": Application.Run "Macro4"
Case "aButton05": Application.Run "Macro5"


Case "aButton06": Application.Run "test"
Case "aButton07": Application.Run "test"
Case "aButton08": Application.Run "test"
Case "aButton09": Application.Run "test"
Case "aButton10": Application.Run "test"


End Select

End Sub

Sub GetVisible(control As IRibbonControl, ByRef MakeVisible)


Select Case control.ID

Case "GroupA": MakeVisible = True
Case "aButton01": MakeVisible = True
Case "aButton02": MakeVisible = True
Case "aButton03": MakeVisible = True
Case "aButton04": MakeVisible = True
Case "aButton05": MakeVisible = True
Case "aButton06": MakeVisible = True
Case "aButton07": MakeVisible = True
Case "aButton08": MakeVisible = True
Case "aButton09": MakeVisible = True
Case "aButton10": MakeVisible = True


End Select

End Sub




So i just need to name the Call backs individually in each template

Paul_Hossler
03-24-2017, 07:42 AM
I put the 3 DOTMs in my XLSTART folder after I changed the CustomUI and the Callbacks and the subs in each

18751


The other 3 attachments just need to have the .zip part removed -- it's just a way of loading DOTMs


Sample of the CustomUI




<!-- This code was created by TheSpreadsheetGuru.com (owned by Guru Solutions, LLC)-->
<!-- All rights are reserved And this code may Not be resold (copyright 2015)-->
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" >
<ribbon>
<tabs>
<tab id="CustomTab" getLabel="modTemplate1.GetLabel" insertAfterMso= "TabDeveloper">
<group id="SpaceGroup0" getVisible = "modTemplate1.GetVisible">
<button id="SpaceButton0" getImage="modTemplate1.GetImage" getVisible = "modTemplate1.GetVisible"/>
</group>
<group id="GroupA" getVisible = "modTemplate1.GetVisible" getLabel="modTemplate1.GetLabel">
<menu id="DDM1" getLabel="modTemplate1.GetLabel" size="large" imageMso="TextAlignGallery" itemSize="large">
<button id="aButton01" getLabel="modTemplate1.GetLabel" onAction="modTemplate1.RunMacro" getImage="modTemplate1.GetImage" getScreentip = "modTemplate1.GetScreenTip" getVisible = "modTemplate1.GetVisible"/>
<menuSeparator id="ms1"/>
<button id="aButton02" getLabel="modTemplate1.GetLabel" onAction="modTemplate1.RunMacro" getImage="modTemplate1.GetImage" getScreentip = "modTemplate1.GetScreenTip" getVisible = "modTemplate1.GetVisible"/>
<menuSeparator id="ms2"/>
<button id="aButton03" getLabel="modTemplate1.GetLabel" onAction="modTemplate1.RunMacro" getImage="modTemplate1.GetImage" getScreentip = "modTemplate1.GetScreenTip" getVisible = "modTemplate1.GetVisible"/>
<menuSeparator id="ms3"/>
<button id="aButton04" getLabel="modTemplate1.GetLabel" onAction="modTemplate1.RunMacro" getImage="modTemplate1.GetImage" getScreentip = "modTemplate1.GetScreenTip" getVisible = "modTemplate1.GetVisible"/>
<menuSeparator id="ms4"/>
<button id="aButton05" getLabel="modTemplate1.GetLabel" onAction="modTemplate1.RunMacro" getImage="modTemplate1.GetImage" getScreentip = "modTemplate1.GetScreenTip" getVisible = "modTemplate1.GetVisible"/>
<menuSeparator id="ms5"/>
<button id="aButton06" getLabel="modTemplate1.GetLabel" onAction="modTemplate1.RunMacro" getImage="modTemplate1.GetImage" getScreentip = "modTemplate1.GetScreenTip" getVisible = "modTemplate1.GetVisible"/>
<menuSeparator id="ms6"/>
<button id="aButton07" getLabel="modTemplate1.GetLabel" onAction="modTemplate1.RunMacro" getImage="modTemplate1.GetImage" getScreentip = "modTemplate1.GetScreenTip" getVisible = "modTemplate1.GetVisible"/>
<menuSeparator id="ms7"/>
<button id="aButton08" getLabel="modTemplate1.GetLabel" onAction="modTemplate1.RunMacro" getImage="modTemplate1.GetImage" getScreentip = "modTemplate1.GetScreenTip" getVisible = "modTemplate1.GetVisible"/>
<menuSeparator id="ms8"/>
<button id="aButton09" getLabel="modTemplate1.GetLabel" onAction="modTemplate1.RunMacro" getImage="modTemplate1.GetImage" getScreentip = "modTemplate1.GetScreenTip" getVisible = "modTemplate1.GetVisible"/>
<menuSeparator id="ms9"/>
<button id="aButton10" getLabel="modTemplate1.GetLabel" onAction="modTemplate1.RunMacro" getImage="modTemplate1.GetImage" getScreentip = "modTemplate1.GetScreenTip" getVisible = "modTemplate1.GetVisible"/>
<menuSeparator id="ms10"/>
</menu>
</group>
</tab>
</tabs>
</ribbon>
</customUI>

dj44
03-24-2017, 10:13 AM
Hello Paul,

thank you very much for taking the time to solve this ribbon problem.

There i was naivley makign all these ribbons - i had 10 in the pipeline - i should walk before i can run :grinhalo:


so that is on hold till i get to write the call backs, make an ID for each one.

Well - its very finicky making these ribbons, and it takes me time to put the macro name with the button and description.

And i nearly had a coronory when the ribbon failed, as i moved the macros from normal template to the ribbon, im very attached to my macros they help me do better at working on the computer.

I ininitally thought it was office 365 problem, but i thought i better check here with the pros regarding this ribbon.

so hopefully i will this weekend start labelling my ribbons.

thanks for takign the time Paul, that was a very frustrating ribbon problem becuase no where does it say what the problem is on the startup when you have more ribbons
and this ribbon was a conflict problem - but i just didnt know how to explain it so thank you

Take Away message : Each Ribbon Custom ui - label the call back with a unique ID and insert that into the xml as well


Hope you all have a great weekend
:beerchug:

Paul_Hossler
03-24-2017, 03:31 PM
There i was naively making all these ribbons - i had 10 in the pipeline - i should walk before i can run :grinhalo:

Why not have one DOTM with your macros in it and only one or maybe two tabs, but each tab having multiple groups?

That's what I do -- not the only way of course, just the way I like

I have a hossler.dotm in my "C:\Users\<userid>\AppData\Roaming\Microsoft\Word\STARTUP\Hossler.dotm" folder and MS Word always displays it


18761

Paul_Hossler
03-25-2017, 11:11 AM
Another thought ...

For your basic ribbon that just calls macros, you really do not need getLabel, getImage, getScreentip, and getVisible callbacks

You can use image =" " or imageMso = " " in the ribbon code



Another another thought ...

You might post and read through this VBAexpress forum also to see if it gives you ideas

Office 2007 Ribbon UI (http://www.vbaexpress.com/forum/forumdisplay.php?96-Office-2007-Ribbon-UI)

dj44
03-26-2017, 10:04 PM
Hello Paul,

I will take your advice and just have one ribbon, it has been an ordeal these buttons and the xml it never fails to fail to break down even when id did nothing wrong :doh:.

It also mad e a conflict with my onenote something about the icons not loading - well i dont really have a clue - but i beter not mess any more in case the computer breaks down because of my ribbon escapades.

Well i was bewitched by a nice Addin ribbon i saw with icons - and thought id get my hands stuck in and make this ribbon, well it started off well a few months ago but then it still failed to start up - but now i know why. I was determined to make this ribbon.

I made copies of it so evey time i loaded a document that had the same code it wouldnt work, but then it would sometimes so i just couldnt work out this conundrum and i upgraded my office - so i thought it was that.

oh well lesson learned newbie folk dont just copy and paste code or mess with xml - leave it to Greg, Paul and the eperienced folk they know what they doing :grinhalo:

Good week to all folks

Paul_Hossler
03-27-2017, 08:20 AM
It really doesn't have to be very complicated to do a basic ribbon

18781


As example I took your 3 DOTMs and merged them and added some non-Office images ('image' vs. imageMso') using the CustomUI editor

18780


XML is pretty straight-forward, and the only callback it the one to run the correct macro based on the button




<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" >
<ribbon>
<tabs>
<tab id="CustomTab" insertAfterMso= "TabDeveloper" label="My Macros">
<group id="GroupA" label="Template Macros">
<menu id="DDM1" size="large" imageMso="TextAlignGallery" itemSize="large" label="Pick Template Macro">
<button id="aButton01" onAction="RunMacro" image="black-king-2d"/>
<button id="aButton02" onAction="RunMacro" image="black-queen-2d"/>
<button id="aButton03" onAction="RunMacro" image="chess-board"/>
<button id="aButton04" onAction="RunMacro" image="chess"/>
<button id="aButton05" onAction="RunMacro" image="white-bishop"/>
<button id="aButton06" onAction="RunMacro" image="white-castle"/>
<button id="aButton07" onAction="RunMacro" image="white-king"/>
<button id="aButton08" onAction="RunMacro" image="white-knight"/>
<button id="aButton09" onAction="RunMacro" image="white-pawn"/>
<button id="aButton10" onAction="RunMacro" image="white-queen"/>
</menu>
</group>
<group id="GroupB" label="Table Macros">
<menu id="DDM2" size="large" imageMso="TextAlignGallery" itemSize="large" label="Pick Table Macro">
<button id="bButton01" onAction="RunMacro" imageMso="A" label="Macro 1"/>
<button id="bButton02" onAction="RunMacro" imageMso="B" label="Macro 2"/>
<button id="bButton03" onAction="RunMacro" imageMso="C" label="Macro 3"/>
<button id="bButton04" onAction="RunMacro" imageMso="D" label="Macro 4"/>
<button id="bButton05" onAction="RunMacro" imageMso="E" label="Macro 5"/>
<button id="bButton06" onAction="RunMacro" imageMso="F" label="Macro 6"/>
<button id="bButton07" onAction="RunMacro" imageMso="G" label="Macro 7"/>
<button id="bButton08" onAction="RunMacro" imageMso="H" label="Macro 8"/>
<button id="bButton09" onAction="RunMacro" imageMso="I" label="Macro 9"/>
<button id="bButton10" onAction="RunMacro" imageMso="J" label="Macro 10"/>
</menu>
</group>
<group id="GroupC" label="Text Macros">
<button id="cButton01" onAction="RunMacro" image="black-king-2d" size="large"/>
<button id="cButton02" onAction="RunMacro" image="black-queen-2d" size="large"/>
<button id="cButton03" onAction="RunMacro" image="chess-board" size="large"/>
<button id="cButton04" onAction="RunMacro" image="chess" size="large"/>
<button id="cButton05" onAction="RunMacro" image="white-bishop" size="large"/>
<button id="cButton06" onAction="RunMacro" image="white-castle" size="large"/>
<button id="cButton07" onAction="RunMacro" image="white-king" size="large"/>
<button id="cButton08" onAction="RunMacro" image="white-knight" size="large"/>
<button id="cButton09" onAction="RunMacro" image="white-pawn" size="large"/>
<button id="cButton10" onAction="RunMacro" image="white-queen" size="large"/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>


Just remove the .zip part of the attachment if you want to see more

dj44
03-29-2017, 08:20 PM
Thanks again Paul,

the Ribbon is nicely working now with images, and the drop down is working as well - just like it shows

I have got it all organised - I'll be sure to write up all my notes so in future - i dont get all tangled again should a mishap happen


Now ive got a oneNote problem something about a call back on the ribbon but I never touched the ribbon
OneNote does not have vba so I dont know what onenotes talking about
oh the fun of office keeps me on my toes
:grinhalo: