Menu | program | create | toolbar VB add-in system do two, create your own sidebar and menu creation toolbar in VB still need to use to VBI, as long as with VB to deal with, must have it, at the same time in the article elaborated the menu item system does the method is to you now will do the work to be useful. One thing you need to know , whether it's creating a button or creating a menu item, there's no difference between them. But there are some places that are a little bit different. How do I create a tool bar? very simple. VBI.CommandBars.Add Cbstoolsbarname There are other optional arguments behind this method, but there are some things that have nothing to do with the problem I'm trying to explain right now. Function ADD ([Name], [Position], [MenuBar], [temporary]) as CommandBar [Position] is the location. is floating in VB or in the top of VB, below, left, right? parameters, you want to refer to MsoBarPosition. As for the [MenuBar] parameter, specify which menu bar you want to go to. Of course, the last parameter, I do not know what the use of it, the single at least will not affect your current work, and will not later. The cbstoolsbarname of VBI.CommandBars.Add Cbstoolsbarname is of course the name of our sidebar. You'd better use a constant approach. Each time you add a button to it, you will save the event of writing Chinese characters, if you write in English, The toolbar name in the menu that appears when the user right-clicks the toolbar is in English. If you write in Chinese, it is Chinese. I'm not a master on the processing toolbar, because so far I can't add a menu to the menu bar and the File menu, just add its subkeys. There was once an attempt to add, But perhaps due to improper, caused another failure. If you know, don't forget to tell me! After you add a toolbar, adding a button to the sidebar is the same as adding a menu item to a menu such as [Tools]. Only the result is added to your sidebar, and the string will be used for the tooltiptext of the button, where you have to have an icon for each button, typically 32* 32. The other size, of course, can be, but it will only deform. Use the Clipboard to load the icon, and then use the PasteFace pasted in the previous article. You can add to the button, regardless of the format. As long as the VB supported graphics. VB support gif But paste on the absolute is not animation. This method simply encapsulates the BitBlt, puts the image of the Clipboard on a DC object, and then bitblt to the button. Even if you load an GIF, the button can only see the first frame of the GIF,It's a good thing to open a GIF with a [drawing] program. I copied a piece of code I used to add a button to your development coderhelper. Maybe it's very useful to you. Public Function Addtomenu (txtcaption As String, Owner as String, Resiconid as Long, Optional before, Optional ID as Long) As CommandBarEvents Dim CMenu as Object set cMenu = AddCommandBar (txtcaption, Owner, Resiconid, before) ' Draw event set Addtomen U = VBI. Events.commandbarevents (cMenu) End Function function AddCommandBar (scaption As String, Owner as String, Resiconid as Long, Optional before) as Office.commandbarcontrol Dim cbmenucommandbar As Office.commandbarcontrol ' command bar object Dim Cbmenu as Comman Dbar on Error GoTo addtoaddincommandbarerr ' see if you can find the add-in menu Set cbmenu = VBI. CommandBars (Owner) If cbmenu is nothing Then ' no valid add-in, procedure failure Exit Function End If ' Add it to command bar Set Cbmenucommandbar = cbmenu.c Ontrols. ADD (1,,, before) ' Set the title cbmenucommandbar.caption = scaption clipboard.clear clipboard.setdata loadrespicture (ResIconID, VBRESBITMAP) ' Set the icon for this button cbmenucommandbar.pasteface clipboard.clear set addcommandbar = Cbmenucommandbar Exit FunCtion addtoaddincommandbarerr:end Function in OnConnection I use this. First VBI. CommandBars.Add myname ' myname is the name constant of the toolbar, public const MYNAME = "Programmer Assistant Toolbar" Public Const MYFUNNAME = "Programmer Helper Shortcut Command" ' These two constants are in module mo Dmain. So it is available throughout the coderhelper. So it's convenient for you to add a button to any of the subroutines. Although I'm not right, the reason is very real, so you are very stupid, disorderly code will make you crazy, so it is best not to do what. Vbi. After CommandBars.Add myname, you can do it like the following code. Set cbevbexport = Addtomenu ("Share DLL Compilation Wizard", MyName, 109) Set pjtexplorer = Addtom ENU ("Engineering browser", MyName, 113) Set ucfileeditor = Addtomenu ("File Editor", MyName, 112) Set wecmdline = Addtomenu ("command line", MyName, 111 109,112,113,111 is the resource code, in AddCommandBar, LoadResPicture (Resiconid, Vbresbitmap) The statement is for bitmap resources. And these numbers are a bit resiconid prepared. The code for you saves you a lot of things, all you have to do is declare an event name for the button, find a picture, find a string, load the picture into a resource file, and then the Set event name = Addtomenu (" String ", toolbar name, picture Resource code) and then, like me in Coderhelper: Private Sub cbevbexport_click (ByVal CommandBarControl as Object, handled as Bo Olean, CancelDefault as Boolean) DoCommand "Vbexport", "" "End Sub That's it. Three of these parameters are obvious. This is not what I want to explain to you now. It's not about the current job. Why not worry about it? Maybe you can see, my coderhe.The command line in Lper is responsible for a number of tasks. You guessed right. In order to run reliably, what programming needs. This way is pretty good. As long as in the DoCommand to handle the error. Don't worry about it anywhere else! and other code. The first button is finished. Adding the second is the same way. The menu is the same. Add items to the menu. It's the same way. You may find that the add-in calls the runtime Mso.dll of office. Including all of Microsoft's big software at present, Almost all of it is used, which is why sometimes office is boring to run Office Setup when it starts VB after the installation changes.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.