Create custom menu and tools for VBE Editor. Auto VBA Code Generator and Shortcuts

Create custom menu and tools for VBE Editor. Auto VBA Code Generator and Shortcuts Hey guys welcome back to my channel if you're new here i'm lon pamai and this week i'll be covering some videos on how to extend your vbe editor using vba.

A while ago we did a series on a custom context menu and ribbon x where we explored various controls and ways to build professional ui within the ribbon itself.

Similarly you can extend your visual basic editor by writing code to to read modify projects modules procedures class even the user form and all these objects.

Okay this is very useful especially for those who spend a lot of time in vba programming because this can be used to automate code templates um obfuscation.

Automatic uh installation of codes or setting references or removing the missing references um indenting codes and so on as we go on i'll try to add more videos.

But for today i'll um show you how to create a custom control uh create a class object to handle click events.

Create custom menu and tools for VBE Editor. Auto VBA Code Generator and Shortcuts

And then we'll also cover some more techniques to automate code templates okay so before we begin if you haven't please do not forget to subscribe and hit the bell icon for.

Upcoming videos before we begin let me give a quick demonstration uh for example here in the insert menu i've added some custom controls in this general category.

I've added all these uh buttons or controls and then under loop i've added these for example and once i click here it's gonna.

Simply populate uh predefined code from the backend which you can set it up in the different ways which will also talk a bit and if i click on uh yeah function is.

Gonna add these and then similarly uh this is another example of a group of controls which you can you know like move it.

Um wherever you want uh for example yeah and leave it there and you can populate multiple of disk uh you know like um like bars and then uh similarly you're gonna.

    Have you know like um for example

    Additional um here's example of a drop down which we already discussed in the custom context menu uh.

    Series um and then you can similarly populate it here itself um okay this is another example and then you can also add.

    Um here's another example if you right click you can also add these uh sub menus down here for example click on a open and then it's going to bring in the codes from.

    Uh from however you want to set those up okay so um i'm gonna walk you through how to create this uh for today and i'm gonna make some of this uh these you know like a digital uh more advanced.

    One for download um uh in the download center okay so just watch out for that okay so let me first close everything we'll start everything from scratch.

    Before you can start writing the code go to your file options and then from the trust center just make sure that you give vba trust access okay so make sure this is.

    Checked and then click on okay so that's one thing and then the second part will be uh go to references and look for microsoft uh visual basic.

    This one microsoft visual basic for application accessibility so your version could be different but just check this box and click on i'm okay save this as um.

    okay so now we can start creating our custom menu let's call this core uh custom monitor.

    First thing we will uh declare

    Our let's call this command bar item as a command bar control okay and then we will associate this with the insert.

    Existing one so we'll say wait application dot uh in our custom context menu we directly did a.

    Common burst but here since we'll be using vba we'll specify this and then we will use command bars and then here uh it's gonna be we will specify this.

    Will be menu bar dot controls and then here we'll specify insert .

    Uh to point to this so if you want to insert it here then you specify help for example okay then end with and then we'll say set.

    here we'll set one bar um will be okay.

    And then uh so first we'll add one and then maybe we'll convert it's this to a function now with this command bar item we can specify the caption caption could.

    Be hello and uh you can specify you know like the index uh where to begin um as well or you can assign the micro that.

    You want to run or you can put a face id like the icon for example let's say i want to put a face id uh equal to maybe two.

    Six four zero i think that was what i was using um and um begin group will be true um and then our action.

    Dot on action here you can specify the name of the macro you want to run so let's say that we have a micro call hello okay here i'll specify this.

    Um it's good to be specific about uh one is pass on this so we can also say this workbook dot name and then we will specify this.

    Okay what else can we add uh a tag because we will also want to recreate we might want to delete.

    So we'll put a tag here we'll say uh main something like that there are additional attributes which you can uh use but for now i think this this uh should be okay and then um.

    Let's test this so here is hello world with arrow mark pointing down okay so uh now you know how to create uh add this using this simple code.

    Um now if i rerun this code then you'll see that there are two of them because we didn't delete it yeah so now in order to delete uh let's write a.

    Code to clean it as well then clean controls something like that and uh vbe command bars control so we'll define the control.

    Let me just copy it like this and i'll just call this control as here specify office and here i'll say set control.

    That will be instead of this we will try to find that tagging okay so find controls and then uh tag is gonna be our um this time.

    Uh this one or we can also okay here we will specify our tagging and here okay um so.

    After we find that we will look through all the uh controls within this and then we will delete them wherever we find this uh this timing.

    Yeah okay so uh do until control is nothing and then we'll control delete and then we will reset.

    This one my keyboard and here we will loop so let's see uh i just ran that um okay.

    Let me try to run this uh okay here we need to remove this part now let's just give it one second application on dvd .

    Rain control okay so that is gone and it's gone uh i need to replicate this block here if i run this there's a code there and one more time too and if i run this to.

    Clean it all those con custom controls are deleted okay so uh here we're defining the controls looping through.

    Finding the one all controls with this tagging and then we are deleting them yeah okay uh now uh ideally if we are doing this.

    Uh part uh in the other controls in the context menu it's supposed to work but uh in vbe we need to um handle this through a class otherwise we will not be.

    Able to uh you know like fire this particular event on action so for that we will write a small code now and i first delete this.

    DISCLAIMER: In this description contains affiliate links, which means that if you click on one of the product links, I'll receive a small commission. This helps support the channel and allows us to continue to make videos like this. All Content Responsibility lies with the Channel Producer. For Download, see The Author's channel. The content of this Post was transcribed from the Channel: https://www.youtube.com/watch?v=wrrWMb34NAw
Previous Post Next Post