Make toolbar visible

2918
2
03-28-2011 11:40 AM
BerndtNording
New Contributor III
I am looking for a .net code snippet that will make a standard ArcMAP toolbar visible. Logically one would just get the CommandBars object, find the toolbar in there and set it visible. Of course, this doesn't work since the commandbars object only has toolbars that are already visible, nor is there any method for adding a toolbar to it.
I've also found some code that uses a CategoryFactoryClass to get a toolbardef object for the toolbar I want, but that's a dead end as well.
This can't be that hard to do!
0 Kudos
2 Replies
NeilClemmons
Regular Contributor III
The CommandBars object can be used to access any toolbar, menu, command, or tool regardless of whether or not it is currently visible in the application.  The following VBA code will toggle the visibility of the 3D Analyst toolbar.  All you need to do is replace the ThisDocument object with a reference to the current document and replace the GUID with the correct value for the toolbar you want.

Sub toggle3dAnalystToolbar()
    Dim uid As New uid
    uid.Value = "{3FA6313B-7EB4-11D4-A10D-00508BD60CB9}"
    
    Dim commandBar As ICommandBar
    Set commandBar = ThisDocument.CommandBars.Find(uid)
    
    commandBar.Dock (esriDockToggle)
End Sub
0 Kudos
BerndtNording
New Contributor III
Thanks, that does work! I was trying to find them using the name of the toolbar which seems to work for custom toolbars but not the built-in ones.

I had to use VBA's arcid to get the UID. In another thread from 2006 you said one could find UIDs by typing GUID into the help, but that does not seem to work anymore in the "new" style help.
I eventually found them under Contents | General Reference | Names and IDs | Arcmap commands,
but there's got to be a better way...
0 Kudos