See the top rated post in this thread. Click here

Results 1 to 8 of 8

Thread: Program to switch to the home tab on the ribbon

  1. #1
    I could stop if I wanted to
    Join Date
    2003-11
    Posts
    450
    Login to Give a bone
    0

    Default Program to switch to the home tab on the ribbon

    I was looking for a keyboard shortcut to activate the home ribbon and have not found anything. Has anybody created something like this?

  2. #2
    I could stop if I wanted to
    Join Date
    2003-11
    Posts
    450
    Login to Give a bone
    0

    Default Re: Program to switch to the home tab on the ribbon

    Here's what I have so far:

    Dim ribcontrol As RibbonControl = ComponentManager.Ribbon
    ribcontrol.ActiveTab = "Home"

    But it gives me a "String" error in Visual Studio.

    Sorry I am very new to .Net

  3. #3
    I could stop if I wanted to
    Join Date
    2003-11
    Posts
    450
    Login to Give a bone
    0

    Default Re: Program to switch to the home tab on the ribbon

    Got it, see below:
    used code from here http://forums.autodesk.com/t5/NET/Ho...ET/m-p/3049040


    Code:
     <CommandMethod("setHomeTab")> _
        Public Sub setHomeTab()
            Dim activeDoc As Document = Application.DocumentManager.MdiActiveDocument
            Dim db As Database = activeDoc.Database
            Dim ed As Editor = activeDoc.Editor
    
            Dim i As Integer
            Dim ribcontrol As Autodesk.Windows.RibbonControl
            ribcontrol = Autodesk.Windows.ComponentManager.Ribbon
    
            Dim cnt As Integer
            cnt = ribcontrol.Tabs.Count
            For i = 0 To ribcontrol.Tabs.Count - 1
                With ribcontrol.Tabs
                    'ed.WriteMessage("Name: " & .Item(i).Name & " ID:" & .Item(i).Id & Environment.NewLine)
                    If .Item(i).Name = "Home - 2D" Then
                        .Item(i).IsActive = True
                    End If
    
                End With
            Next
        End Sub

  4. #4
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: Program to switch to the home tab on the ribbon

    Nice! Just a few queries :
    Why the db variable? It's never used.
    What about if the Home tab is named slightly differently? Say "Home - 3D"?

  5. #5
    I could stop if I wanted to
    Join Date
    2003-11
    Posts
    450
    Login to Give a bone
    0

    Default Re: Program to switch to the home tab on the ribbon

    It was a cut and paste from the noted website, I should have reviewed it more in detail. I should have removed the db variable, it looks like it is not needed. If you would like the "Home - 3D" tab current just substitute "Home - 2D". I had to hard code "Home - 2D" because I assigned the program to a shortcut key (F1) with in the CUI.

  6. #6
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,418
    Login to Give a bone
    0

    Default Re: Program to switch to the home tab on the ribbon

    Quote Originally Posted by GreyHippo View Post
    It was a cut and paste from the noted website, I should have reviewed it more in detail. I should have removed the db variable, it looks like it is not needed. If you would like the "Home - 3D" tab current just substitute "Home - 2D". I had to hard code "Home - 2D" because I assigned the program to a shortcut key (F1) with in the CUI.
    On this line: If .Item(i).Name = "Home - 2D" Then , you could use the Like operator instead of =.
    C:> ED WORKING....


    LinkedIn

  7. #7
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: Program to switch to the home tab on the ribbon

    Quote Originally Posted by Ed Jobe View Post
    On this line: If .Item(i).Name = "Home - 2D" Then , you could use the Like operator instead of =.
    +1

    Or you could have it ask for input and set according to the string "entered". That way you can have a macro call your function with any of the ribbon tab names. No need to duplicate your function several times for other tabs.

    Or even more "usable" would be to turn it into a Lisp-callable function, taking an argument as the Tab name.

    What I'd do though is generate an inspection function returning a list of tab names. And/or even one which returns the currently active tab. But that's probably a bit too much ... just trying to think ahead.

  8. #8
    Active Member
    Join Date
    2009-08
    Posts
    93
    Login to Give a bone
    1

    Default Re: Program to switch to the home tab on the ribbon

    If you want the Home Tab I think they all start with "Home" and if so this could work

    Code:
                        If .Item(i).Name.StartsWith("Home") Then
                            .Item(i).IsActive = True
                        End If

Similar Threads

  1. Way to switch back to Home tab?
    By kristy in forum AutoCAD General
    Replies: 4
    Last Post: 2016-08-16, 05:01 PM
  2. 2014: What happened to ACA Home ribbon? Migrate Issue?
    By bjm in forum ACA General
    Replies: 1
    Last Post: 2013-07-09, 04:02 PM
  3. 2012: Contextual ribbon tab not switch
    By nguyentruongphat113230390 in forum AutoCAD Customization
    Replies: 0
    Last Post: 2012-05-03, 08:28 AM
  4. Is there a shortcut to display the home tab in the ribbon?
    By GreyHippo in forum AutoCAD Customization
    Replies: 5
    Last Post: 2011-10-06, 06:35 PM
  5. Home Tab in Ribbon is Missing
    By cdsuggs in forum Revit MEP - General
    Replies: 1
    Last Post: 2010-06-30, 06:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •