Is it possible to load one or another Ribbon with the same template?
-
4 mai 2012 07:13
Hi,
I have a Word Template (Word 2007 or 2010, VBA) with it's own custom ribbon.
I will create or open a document based on that template from Access.
The same template will serve (with same change) to manage two different documents. The two kind of documents need to have different Ribbons.
I would like to be able to tell word if X load ThisRIbbon alse load ThatRibbon.
Is it possible?
Thanks, Lauro
Toate mesajele
-
4 mai 2012 12:40
Hi Lauro,
Look into the XML command GetVisible. If, depending on some criteria, you need to display different ribbon controls then this is the command to use. For example, if you have a custom tab of controls that are different depending on the application version, then you actually load both tabs but then set the GetVisible property to True and False for the appropriate tabs to display based on the criteria.
Hope this helps
Kind Regards, Rich ... http://greatcirclelearning.com
- Editat de Rich Michaels 4 mai 2012 12:44
- Editat de Rich Michaels 4 mai 2012 12:45
-
4 mai 2012 18:44
Thanks Rich,
Ok, I will try as you suggest.
Do you think is enough to set GetVisible and GetEnabled only to one of the two TAB or should I change also the status of each controls?
Lauro
-
4 mai 2012 22:37
Hi Lauro,
If the tab isn't visible there's no need to disable the controls it contains.
With that said, if there's another way that certain macros that are contained in the template can be executed and those macros should only be executed if the Office version is 2007, then before executing you should validate that the application.version is 12.0.
Kind Regards, Rich ... http://greatcirclelearning.com
- Editat de Rich Michaels 4 mai 2012 22:40
- Marcat ca răspuns de Lauro2 5 mai 2012 09:30
-
5 mai 2012 06:58Moderator
Hi Lauro
You can do everything as Rich explains. However, it's important that you realize the user can "see" the controls you're "hiding" via the Customize command for the Ribbon / QAT. And the user can add them to the QAT through this method. So it would be important for you to disable the controls, not just hide the groups.
Using VBA there is no alternate method for loading Ribbons. If these were VSTO documents or a VSTO add-in for Word, then it would be possible to define the XML at run-time. But VSTO means programming and distributing using the .NET technology.
Another possible way to go would be to change the RibbonXML before loading the document in Word. The Word template is an Open XML Package of XML files. Using tools that can work with ZIP files, you can (for example) add / exchange the XML file that defines the Ribbon. There's a series of articles on how to use VBA to zip/unzip files here: http://www.rondebruin.nl/tips.htm (scroll down almost to the bottom) and here http://www.jkp-ads.com/articles/Excel2007FileFormat02.asp. In this last, see specifically for changing the Ribbon the sections about extracting XML from the file structure and writing back XML to the file structure as this is what you'd need to exchange the ribbon XML file.
If you need a different ribbon for 2007 vs 2010 then see this article: http://www.rondebruin.nl/ribbonx20072010.htm
Cindy Meister, VSTO/Word MVP
- Marcat ca răspuns de Lauro2 5 mai 2012 09:30
-
5 mai 2012 09:30
Thank again to both of you for your valuable help.
Lauro