Consulting

Results 1 to 2 of 2

Thread: Set a reference to the current ribbon

  1. #1
    VBAX Regular
    Joined
    Feb 2011
    Posts
    27
    Location

    Set a reference to the current ribbon

    I want to begin using the IRibbonUI and IRibbonControl objects but I do not know how to get started.


    I was thinking maybe something like

    [vba]Dim theRibbon as IRibbonUI

    set theRibbon=activedocument.Ribbon
    'or
    set theRibbon=application.Ribbon[/vba]

    I know that that does not exist, but how do I set the ribbon control to the current ribbon?




    The web is full of articles about how to create a custom ribbon or modify the ribbon. I do not want to do any of that I just want to work with the current ribbon.


    When I am done, I will do something like this





    [vba]For each ribControl in theRibbon
    debug.print ribControl.id
    next RibControl
    [/vba]


    So, in Word, Excel, or PowerPoint, how do I set a reference to the current ribbon?

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,727
    Location
    Use

    [VBA]
    <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"onLoad="Ribbon_OnLoad" >
    [/VBA]

    in the XML and

    [VBA]
    Public oRibbon As IRibbonUI


    'Callback for customUI.onLoad
    Public Sub Ribbon_OnLoad(ribbon As IRibbonUI)
    Set oRibbon = ribbon
    End Sub
    [/VBA]

    in a standard module

    That way you can use

    [VBA]
    oRibbon.Invalidate
    oRibbon.InvalidateControl
    [/VBA]

    to have the ribbon update its setting, etc


    Paul

Posting Permissions

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