First comment... My preference is to use the semicolon, rather than a space. Both would work under most circumstances. I also am in the habit of putting two Ctrl-C's (^C^C) on the front of any macro that can not be run transparently (while another command is prompting). That will make sure that if the user clicks the button while a command is in progress, it will cancel the previous command before attempting to run the new one.
Second, I can't find the signature for this AddToolbarButton Method in the object browser, so either you are on an older version than me, or have something referenced that I don't, or it's one of your own functions. (I'm on 2010, AcCui and AcCustomize referenced)
Anyway, this is some code I have which will create a new .CUIX file with a toolbar and three buttons if it does not exist. This code will not load the new menu, though. This is all I've got that deals with menus in Managed code. I had to edit some of the strings to shorten the lines, but I tried to leave enough to tell what's going on.
Theoretically, this code could be slightly adapted to add the toolbar and buttons to the main customization section af the acad menu, instead of a separate partial menu, but I tend to avoid adding things to the acad base menu.
{code}
Dim pcs As CustomizationSection = New CustomizationSection
pcs.MenuGroupName = "SR2GMTRS"
Dim mg As MacroGroup = New MacroGroup("SR2GMTRSMacros", pcs.MenuGroup)
mg.CreateMenuMacro("Name", "^C^Cmcp-loc;", "ID_MCPLOC", "Tooltip", Any, "1.bmp", "1.bmp", Nothing)
mg.CreateMenuMacro("Name", "^C^Cmod-pnl;", "ID_MODPNL", "Tooltip", Any, "2.bmp", "2.bmp", Nothing)
mg.CreateMenuMacro("Name", "^C^Cmcpol;", "ID_MCPOL", "Tooltip", Any, "3.bmp", "3.bmp", Nothing)
Dim sc As New Collections.Specialized.StringCollection
sc.Add("SR2G Mtrs Main")
Dim tb As New Toolbar("TBname", "Description", "ID", sc, True, floating, 200, 200, 1, pcs.MenuGroup)
Dim btn1 As New ToolbarButton("ID_MCPLOC", "Locate MCP Panels", tb, -1)
Dim btn2 As New ToolbarButton("ID_MODPNL", "Modify MCP Panel", tb, -1)
Dim btn3 As New ToolbarButton("ID_MCPOL", "Draw MCP Oneline", tb, -1)
tb.ToolbarItems.Add(btn1)
tb.ToolbarItems.Add(btn2)
tb.ToolbarItems.Add(btn3)
pcs.SaveAs(My.Application.Info.DirectoryPath & "\SR2Gelec.cuix")
{code}
Edited by: chiefbraincloud on Jan 6, 2010 5:52 PM
So much for attempting to make the formatting readable... but I also forgot to mention this code was written for Acad2009, not 2010, the only difference being that the file extension should be .CUI for 2009 instead of .CUIX. That said, I'm not 100% sure, but I think some of these Objects and/or methods were new to the 2009 API, so I don't think it could be made to work for 2008 or before.
Dave O.