Avatar of GreyHippo
GreyHippo

asked on 

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

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 vb.net 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

Visual Basic.NETCAD/Architecture Software

Avatar of undefined
Last Comment
GreyHippo
Avatar of silverkorn
silverkorn
Flag of United States of America image

see the discussion here:
http://forums.autodesk.com/t5/NET/How-to-Load-CUI-File-Ribbon-Tabs-And-Make-Visible-via-NET/m-p/3049040

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

ASKER

That's what I started with but I can't figure out how to add the name of the tab to make active.
Avatar of silverkorn
silverkorn
Flag of United States of America image

as per: http://forums.autodesk.com/t5/NET/Options-Dialog-Tab-Pre-Selection/m-p/2400125/highlight/true#M12755

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

another example could be found here:
http://forums.autodesk.com/t5/NET/Total-n00b-trying-to-use-net-to-create-ribbon-bar-addins/m-p/2880120/highlight/true#M22189

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
        ribCntrl.Tabs.Add(ribTab)
        'set as active tab
        ribTab.IsActive = True

    End Sub

Open in new window

Avatar of GreyHippo
GreyHippo

ASKER

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.

ASKER CERTIFIED SOLUTION
Avatar of silverkorn
silverkorn
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of GreyHippo
GreyHippo

ASKER

Thanks that worked
Visual Basic.NET
Visual Basic.NET

Visual Basic .NET (VB.NET) is an object-oriented programming language implemented on the .NET framework, but also supported on other platforms such as Mono and Silverlight. Microsoft launched VB.NET as the successor to the Visual Basic language. Though it is similar in syntax to Visual Basic pre-2002, it is not the same technology,

96K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo