Rename the “User Commands” panel

<?xml encoding=”UTF-8″>By Adam Nagy

When adding VBA macro functions to the Ribbon through the “Customize User Commands…” button then they will appear in the “User Commands” panel.

UserCommands

RibbonPanel names cannot be changed, but maybe the panels could be replaced by other ones.

Instead of doing that though, I think the easiest might be just to create your own panel and add the macros to that. 

In this case I only have these two macros in my “Module1” and when I run “CreateMyPanel” then it will create a new panel called “MyPanel” and add a reference in it to the “MyMessage” macro.

Module1

Sub MyMessage()
MsgBox "My message"
End Sub
Sub CreateMyPanel()
Dim rs As Ribbons
Set rs = ThisApplication.UserInterfaceManager.Ribbons
Dim cds As ControlDefinitions
Set cds = ThisApplication.CommandManager.ControlDefinitions
Dim cd As MacroControlDefinition
Set cd = cds.AddMacroControlDefinition("Module1.MyMessage")
Dim r As Ribbon
Set r = rs("Part")
Dim t As RibbonTab
Set t = r.RibbonTabs("id_TabTools")
Dim p As RibbonPanel
Set p = t.RibbonPanels.Add("MyPanel", "MyName.MyPanel", "MyName.MyPanel")
Call p.CommandControls.AddMacro(cd)
End Sub

MyPanel

One thing to bear in mind is that programmatically added UI elements are not persisted. So you would have to run your command that adds the extra ribbon panel each time Inventor starts. The best way to do that would be to create an addin for that.  

 


Comments

3 responses to “Rename the “User Commands” panel”

  1. Klaas De Smedt Avatar
    Klaas De Smedt

    Is there a simple Addin that runs a pre defined macro for such tasks? Preferably published by Autodesk?

  2. Thanks Adam Nagy!

  3. Hi Klaas,
    I’m not aware of such an addin.
    If you want to do UI customisation the best might be to migrate your code to an add-in: http://modthemachine.typepad.com/my_weblog/2008/10/converting-vba-auto-macros-to-an-add-in.html
    Now it’s even simpler than in the article I’ve pointed out because of the RegFree registration: http://adndevblog.typepad.com/manufacturing/2012/05/creating-or-migrating-your-inventor-add-ins-to-the-registry-free-format.html
    Cheers,
    Adam

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading