1. You are viewing our forum as a guest. For full access please Register. WindowsBBS.com is completely free, paid for by advertisers and donations.

[How do I add a new tab to the Excel 2007 menu?]

Discussion in 'Other PC Software' started by w.young, 2008/10/22.

  1. 2008/10/22
    w.young

    w.young Inactive Thread Starter

    Joined:
    2002/01/07
    Messages:
    291
    Likes Received:
    0
    In Excel 2007 there are tabs with a ribbon bar. Each tab displays a different ribbon of icons.
    I would like to add a new tab on the bar called "drawing tools / format tab ". I use the drawing features quite a bit and in Excel 2003 you were able to add that toolbar on the bottom of the window.
    How do I add a new tab in 2007.
    Thanks.
    Bill
     
  2. 2008/10/22
    Bilb0

    Bilb0 Inactive

    Joined:
    2007/07/23
    Messages:
    203
    Likes Received:
    6
    I have done it in Access, but it is very complicated (when compared to simply creating a new toolbar).

    I would assume it is possible in all of the Office Applications:

    In Access 2007, you have to:
    1. Create a Table which contains the actual Tab code in XML format.
    2. Create VBA code which connects to the database, reads the XML in the table, and creates the Tab
    3. An Autoexec Macro which calls the VBA function that runs OnOpen.

    Shazam, it works.

    Now in theory, the same may be possible via different methods in Excel, but for Word or PowerPoint, you would probably have to still house the XML for the Tab(s) in a Database.

    If you're not deterred, and if you think it might help, I could post some sample code from my working Access 2007 example.
     
    Last edited: 2008/10/22

  3. to hide this advert.

  4. 2008/10/25
    Bilb0

    Bilb0 Inactive

    Joined:
    2007/07/23
    Messages:
    203
    Likes Received:
    6
    In the interest of future visitors, I think it may be best to go ahead and post some sample code:

    =====================================================

    Here is the Table contents (Table name = "DbRibbons ":
    (Field name) = ID, (Contents) = 1
    (Field name) = RibbonName, (Contents) = HideData
    (Field name) = RibbonXml, (Contents) =
    <customUI xmlns=" "http://schemas.microsoft.com/office/2006/01/customui" ">
    <ribbon startFromScratch=" "false" ">
    <tabs>
    <tab idMso=" "TabHomeAccess" " visible=" "false" " />
    <tab id=" "dbCustomTab" " label=" "A Custom Tab" " visible=" "true" ">
    <group id=" "dbCustomGroup" " label=" "A Custom Group" ">
    <control idMso=" "Copy" " label=" "Copy Data" " enabled=" "true" "/>
    <control idMso=" "Paste" " label=" "Paste Data" " enabled=" "true" "/>
    </group>
    </tab>
    </tabs>
    </ribbon>
    </customUI> "

    =====================================================

    Here is the VBA Code (saved in a module):
    Function LoadRibbons()
    Dim i As Integer
    Dim db As DAO.Database
    Set db = Application.CurrentDb
    For i = 0 To (db.TableDefs.Count - 1)
    If (InStr(1, db.TableDefs(i).Name, "Ribbons ")) Then
    Dim rs As DAO.Recordset
    Set rs = CurrentDb.OpenRecordset(db.TableDefs(i).Name)
    rs.MoveFirst
    While Not rs.EOF
    Application.LoadCustomUI rs( "RibbonName ").Value, rs( "RibbonXml ").Value
    rs.MoveNext
    Wend
    rs.Close
    Set rs = Nothing
    End If
    Next i
    db.Close
    Set db = Nothing

    End Function

    =====================================================

    The Macro is easy. name it AutoExec, and give it one line of functionality:
    Action = RunCode
    Arguments = LoadRibbons()

    =====================================================

    As I mentioned, this works for Access 2007.
    Obviously, there would need to be some variation of activation and loading (instead of the AutoExec Macro) for other Office 2007 Apps (which I have not yet tried), but the essential XML and VBA should be relevant to all.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.