Trying to make a ribbon tab active in AutoCAD 2012 using VB.NET

Posted on 2011-10-05
Last Modified: 2012-05-12
I am trying to write a simple program for AutoCAD 2012 using VB.NET to make a specific tab in the ribbon active but since I am very new to am having trouble with it, below is the main part of the program.  Visual Studio is giving me an error for "Home" stating:

Value of type 'String' cannot be converted to 'Autodesk.Windows.RibbonTab'

"Home" is the name of the ribbon tab which I would like to make active.
Private Sub SetRibbonTab()
   Dim ribcontrol As RibbonControl = ComponentManager.Ribbon
   ribcontrol.ActiveTab = "Home"
End Sub

Open in new window

Question by:GreyHippo
    LVL 12

    Expert Comment

    see the discussion here:

    a user had uploaded a sample code file that shows the switching of ribbon tabs

    Author Comment

    That's what I started with but I can't figure out how to add the name of the tab to make active.
    LVL 12

    Expert Comment

    as per:

    it appears that the ActiveTab is looking for an integer value, so try the value of 1

    another example could be found here:

    in which they use the following code to create a new tab and set it active:
    Private Sub CreateRibbon()
            'declare a ribboncontrol object
            Dim ribCntrl As RibbonControl = ComponentManager.Ribbon
            'create a ribbontab
            Dim ribTab As New RibbonTab()
            'set a few properties
            ribTab.Title = "AU2009"
            ribTab.Id = "AU2009"
            'add the tab to the ribbon
            'set as active tab
            ribTab.IsActive = True
        End Sub

    Open in new window


    Author Comment

    I tried adding a 1 but received a similar error: "Value of type 'Integer' cannot be converted to 'Autodesk.Windows.RibbonTab' "

    I found that other example but they are trying to create a new tab and making it active.

    LVL 12

    Accepted Solution

    after looking more closely at the code from the previous link:

    at the very end of the Class1.vb file in the VBExample file they have a for loop to find the tab named Autodesk and then set it active, so from there you could try this line of code to replace your line 3:

    ribcontrol.Tabs.Item(0).IsActive = True

    Author Closing Comment

    Thanks that worked

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    Article by: Kraeven
    Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
    A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now