Results 1 to 5 of 5
  1. #1
    5 Star Lounger kmurdock's Avatar
    Join Date
    Feb 2003
    Location
    Pacific Grove, California, USA
    Posts
    716
    Thanks
    10
    Thanked 34 Times in 28 Posts
    Hi All,

    Not sure if this is the best forum to post, but I have to start somewhere...

    Thanks to the wisdom on the internet (especially Greg Maxey and Ron de Bruin), I have created a Word document template that, when loaded, adds a tab with four groups on it. Initially, one group is visible and the other three are not. There are controls on the visible group that toggle visibility of the other three groups individually. This all works perfectly; it's a combination of the xml file settings and some fairly straightforward VBA.

    I have now tweaked this template so the groups appear on a custom tab (defined in a global template). I have defined a namespace in both the global template and the doc template, and the groups all insert on the global template's tab. But that's the problem. I can no longer toggle the visibility of the groups. They are simply visible and no amount of tweaking has made it work yet. The toggle buttons update, but I cannot coax the three "happy face" groups to update. The toggle buttons all have a straightforward "id" tag, whereas the groups all have "idQ" tags so they can recognize the namespace.

    I invalidate each group and toggle button individually. When I step through the vba code that does the invalidating, I get an error "Can't execute code in break mode" when it reaches to code that affects the toggle button. Not a peep on the code that affects the group. If I invalidate the whole ribbon, the toggle buttons DO refresh, and the three groups do not.

    My code addresses the groups by their control.ID and I think that's where the problem lies (remember they have an idQ tag), but given the complexities of the xml/VBA interaction, I can't debug it to find out if there is no control.ID or if it's different because of the idQ tag.

    So, any takers?
    Best, Kim
    [attachment=89511:visibility.png]

    Has anyone grappled with this issue? I realize it's one of those "out there" scenarios, but it would be very handy for me to resolve it.
    Attached Images Attached Images

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,853
    Thanks
    4
    Thanked 259 Times in 239 Posts
    Kim

    I have built code to create and disable ribbon items which should be the same method as changing visibility. Can you post the template or perhaps the customui and the module it is pointing at?

    One possible gotcha I have encountered when moving working code to another template/module is the need to specify the onAction macro by including the module name. For instance if onAction="mycallback" fails then I try out onAction="mymodule.mycallback"
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. #3
    5 Star Lounger kmurdock's Avatar
    Join Date
    Feb 2003
    Location
    Pacific Grove, California, USA
    Posts
    716
    Thanks
    10
    Thanked 34 Times in 28 Posts
    Hi Andrew and thanks for taking a look,

    I've significantly simplified each of the templates: change the extensions of each zipped file to .dotm. Put GlobalRibbonX in your startup folder (there are no macros in this file anymore). Then open DocRibbonX to see how it works and how it doesn't work. The three toggle buttons are clearly running their VBA code without any confusion.

    As I mentioned in the first post, Added Groups 1, 2 & 3 should be hidden when you first open the template, then toggle visibility when you click the appropriate toggle button. If the xml is not sharing namespace and has its own tab, this is the way it works.

    I thought at first the onload sub wasn't setting the ribbon object, but it invalidates the toggle button controls with no problem.

    It looks like the control.ID (set by idQ in the xml) might be the issue. Or... it's possible the getVisible tag isn't running the VBA sub that sets visibility. Perhaps it's more than one thing....

    I've tried more than one way to debug this thing, but to no avail. If you can shed any light on it I will be very grateful.

    Best, Kim
    [attachment=89545ocRibbonX.zip]
    [attachment=89546:GlobalRibbonX.zip]
    Attached Files Attached Files

  4. #4
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,853
    Thanks
    4
    Thanked 259 Times in 239 Posts
    After much trial and error, I can see your problem but can't solve it directly. It appears that the getVisible dynamic attribute doesn't work on Groups.

    If you move the getVisible dynamic attribute onto the control inside the group rather than the group itself then the button visibility can be made dynamic but the same doesn't appear to work at the group level. The following is the changes I made to get the control showing or hiding correctly.

    <group idQ="nsP:AddGroup1"
    label="Added Group 1"
    insertAfterQ="nsP:NewGroup">
    <button id="hideshowbutton"
    imageMso="HappyFace"
    getVisible="RibbonXP.GetGroupVisible1" size="large"/>
    </group>

    'and the VBA code changes
    Code:
    Sub MyActionMacro1(ByVal control As IRibbonControl, pressed As Boolean)
      If control.ID = "TB1" Then bState1 = Not bState1
      myRibbon.InvalidateControl ("hideshowbutton")
      myRibbon.InvalidateControl ("TB1")
    End Sub
    
    Sub GetGroupVisible1(ByVal control As IRibbonControl, ByRef returnedVal)
      returnedVal = bState1
    End Sub
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  5. #5
    5 Star Lounger kmurdock's Avatar
    Join Date
    Feb 2003
    Location
    Pacific Grove, California, USA
    Posts
    716
    Thanks
    10
    Thanked 34 Times in 28 Posts
    Aye me Andrew,

    It sounds like you wrestled with it just as much as I did. I was also able to hide the buttons, but that won't get me where I need to go -- an empty group still takes up room on the ribbon.

    I think we may have been grappling with a bug. As I noted, I can toggle Group visibility with no problem when the Groups and controls involved are on their own tab. It just doesn't seem to work within the Namespace context. However, if I put the controls on their own tab, I don't have the space issue I was trying to address. Bummer.

    Thank you, thank you, thank you, for your effort. If nothing else, it's freed me to move along to a different solution.

    Best, Kim

Posting Permissions

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