Detail how to create a custom ribbon and also manipulate existing commands using XML if you followed our ribbon AK series for VBA is going to be pretty much the same or I would say even more simplified.
In VST o if you just need the ribbon with standard controls like buttons drop down edit box or label visual designer can take care of all this however if you want to repurpose building commands or.
Define context menus or take care of the backstage you know like menu bars and so on you only the ribbon xmo so it's much more powerful and advanced as compared to the visual designer before we begin.
If you haven't please do not forget to subscribe for latest updates and also to support my channel so here's what we did in our prior episode first going to disarrange.
For a quick recap there is nothing we've done in that this is just supplying foam and then the user control and so mainly the focus was on the ribbon design so this is what we design in our prior.
The visual designer but there are certain things that cannot be done using this visual designer so XML part comes in again we've done this in VBA and if you haven't seen that it is very useful.
Video series you should definitely check it out ok so this is a label that is automatically assigned with the user name and application user name and then the environ ID and then the you know.
Like just label again the version and then this is so the task pane source the wind foam this is example of combobox and a drop down and then whatever you like spin it.
Out here and then this is edit box that automatically recalculates total for example and this is example of check box okay so we'll try to do this similar thing in the XML now you can straight.
Away export this into ribbon and then start doing it here as well we'll put it in the different projects so that it's easier to follow for now let me just export this XML.
You'll see it's automatically generated
So even though this has been generated at the moment you'll see these are the steps that we need to follow to be able to implement this if I load this up now.It's going to be still the same so here okay so it still works everything the same okay now if you look here here's our XML that was exported this is the XML from this designer driven design.
This one and then this is where the code goes okay now expert instruction here we need to add this in the you know I add in or workbook load events or document and then that is how it's gonna take a.
Field effect okay so what I'm gonna do now I'm just gonna take a backup of this XML so that we can reuse this easily I'm gonna first close this solution we'll start a new project again we'll.
Create a add in let's call this add an eczema or something so if you'd not follow the price you a video let me do this I didn't know X so adding okay so we'll use this one this template.
And this cold is Excel add-in and then Exim or ribbon something like that and then I'm gonna place this in the YouTube directory and I'm gonna leave the framework as it is okay so again this is.
Just a template it does not contain anything at the moment now I'm gonna go and add component so in our last video we added this component now we'll add this driven XML I'll just leave the name.
As it is okay so this is the same one that was auto-generated earlier when we were ordering this okay and then here is the XML okay this is just like some code Rd R which were you can utilize now what.
It says here is copied the following this and paste it there we'll do that and then here all this our place where we are gonna put our callback this is where we will be putting all our.
Callbacks I'm just gonna leave this part
As it is okay so first I'm gonna copy this go to this again if you're designing if your project is workbook level or document.Level you paste it here in that this workbook or this document so we are here now so I'm going to uncomment this okay so in the prior project if you want to use the XML then this is for your face.
And then automatically it will instead of picking up the visual designer ribbon that you've done is gonna pick up the XML from the XML file okay so if I load this up now we have not done any.
Customization so we should not see any tab rather we will install the prior ahead and uninstall sir so this is from the prior one I'm now gonna maybe just take.
A snippet so that we can easily refer to it I'm gonna uninstall this for now so this is a new add-on that we just created okay so now there is no ribbon now coming back here let's go and put in.
Start putting down okay so this is again we've gone through this this is the code that's gonna run on load and then this is the namespace schema and okay we'll go one by one and then it should not be.
Difficult my group okay there must be a group in my head instead let's just quickly load this again okay there is none just leave it.
Let's copy this group first so see the tag ends here and it begins here okay and this one is ending here it so it starts and ends here so this is of no use for us maybe we'll just copy it from.
Here till here so if we load this up now it will show but it's been an error let's call this XML this is the label for that new tab and then these are all the labels ctrl.
F5 to open without debugging so here's a ribbon and then all of them seems to be there it's gonna give an error because there's no callback okay so to dynamically let's first assign a label.
On load and then we can perhaps reuse the same code so that we don't have to rewrite everything so opening this we can reuse some of this instead of this static label 1 2 & 3 we'll assign this.
Dynamically again this is case sensitive so get label this is for a callback or you can say for event get label okay so on get label we will assign the code that we want to run here okay so let's.
Call this oh sorry get label I'll just put a name like this okay and going to ribbon here this is where all the callbacks so starts here and then any ends here okay so we'll.
Assign and all this needs to be public okay if you use remember well we're doing for VBA if we use this custom UI you can automatically generate the callback signatures like the syntax but.
Here it's you have to do this okay the name is going to be this and well let's see this can be like a control variable control as this okay so in excel when we do VBA we just need to.
Assign it like this but here we need to assign in full syntax like this and then we can say this is equal to this right hello for now like this or we can just make this to function it will return the.
String and return hello irrespective of the control it will return hello now let's try it first so if there is any error it will be highlighted here as well even in the XML so it's much better.
Than the one that we used earlier signature mismatch okay this give me one second okay it's my but this supposed to be the control okay so hello hello hello so based on.
The control idea we can assign the label now for this we can use select keys and ID dis control workers at that point of time okay so case so the name here oops the.
Name here is the label one so first one of the case is this case two and three K is else it'll return nothing let's get rid of this so in the label one we want to.
Return hello and the username so we can reuse this code that we use in another one here return if this control ID on runtime when it's refreshing is label 1 then we want to return this ok and then.
If it is the second label we want to return this and then the version info here it's kind of you turn this ok so let's give it a shot so now here it returned dynamically okay.