none
Word building blocks: Refreshing gallery entries? RRS feed

  • Question

  • On my ribbon, I'm displaying the building blocks in "Custom 1" gallery, using:

            <gallery  idMso="CustomGallery1" label="Reuse" size="large" />

    I'm programmatically adding a building block to that gallery using BuildingBlockEntries.Add, adding the building block to mytemplate.dotx

    The problem I'm having is that when the user clicks on the gallery to see its entries, the new entry is not displayed.

    The new entry is immediately present in the building blocks organizer.

    The new entry does display on the quick access toolbar after right clicking to add the gallery there (but it still doesn't display in the gallery in my ribbon).

    The new entry does display in my gallery after Word is restarted

    How to get it to refresh?

    - invalidating the ribbon doesn't help

    - saving mytemplate.dotx doesn't help

    - Globals.ThisAddIn.Application.Templates.LoadBuildingBlocks() doesn't help

    Interestingly, when a new building block is saved manually via a click on "Save selection to quick part gallery", it does show up immediately in the gallery on my ribbon.   For one I have added programmatically though, merely looking at it in the building blocks organizer is not enough to force it to show up via the gallery on my ribbon.  Nor is using it.  But editing its properties is.

    Maybe I can programmatically remove the gallery from my ribbon, and then add it again.  Any better ideas?

    Testing conducted here with Word 14.0.6112.5000 (64 bit).


    • Edited by Jason 8659876 Wednesday, July 25, 2012 3:50 AM more detail
    Wednesday, July 25, 2012 3:38 AM

Answers

  • It is a valid idMso; it is listed in Office 2010 Control Ids:

    Control Name Control Type Tab Set Tab Group/Context Menu Name Parent Control Secondary Parent Control Tertiary Parent Control Policy ID Ordering
    CustomGallery1 gallery None (Not in the Ribbon) None (Not in the Ribbon) 15230 1437

    Thursday, July 26, 2012 12:35 AM
  • HI Jason

    Thanks for letting us know it worked - and what worked. I was going to suggest changing the Installed property, but I thought, given what you'd already tried, that it wouldn't be enough. Glad to learn it was!


    Cindy Meister, VSTO/Word MVP

    Thursday, July 26, 2012 9:14 AM
    Moderator

All replies

  • Hi Jason

    Is mytemplate.dotx loaded as a template add-in? If yes, try using the Addin.Delete method to unload it, then the addins.Add method to load it again.

    If it's not loaded as a template add-in, try doing that and see if it makes a difference in the behavior.

    Another approach you could try is to emulate the end-user command using Commandbars.ExecuteMso to call it.

    If that still doesn't help, I recommend we move the question to the more specialized Word for Developers forum where you'll have better chances of encountering someone with experience in this area.


    Cindy Meister, VSTO/Word MVP

    Wednesday, July 25, 2012 8:54 AM
    Moderator
  • Hi Jason,

    <gallery idMso="CustomGallery1" label="Reuse" size="large" />

    I never see this kind of idMso. I'm wondering whether "CustomGallery1" is a id which you customized. If it is, I think you must use id in you tag instead of idMso.

    T.X.


    征诛志异,三让两家王朝
    功同开辟,一桮万古江南


    Wednesday, July 25, 2012 12:23 PM
  • Yes, it is loaded as a template add-in.  It turns out the following does the trick:

                // Hack to force our gallery to refresh
                addinObj.Installed = false;
                addinObj.Installed = true;
    Thanks for the suggestions :-)

    Thursday, July 26, 2012 12:31 AM
  • It is a valid idMso; it is listed in Office 2010 Control Ids:

    Control Name Control Type Tab Set Tab Group/Context Menu Name Parent Control Secondary Parent Control Tertiary Parent Control Policy ID Ordering
    CustomGallery1 gallery None (Not in the Ribbon) None (Not in the Ribbon) 15230 1437

    Thursday, July 26, 2012 12:35 AM
  • HI Jason

    Thanks for letting us know it worked - and what worked. I was going to suggest changing the Installed property, but I thought, given what you'd already tried, that it wouldn't be enough. Glad to learn it was!


    Cindy Meister, VSTO/Word MVP

    Thursday, July 26, 2012 9:14 AM
    Moderator