Answered by:
Hiding the Backstage SaveAs tab

Question
-
There doesn’t appear to be a way to dynamically hide the backstage SaveAs tab (ID is TabSave). One can hide it in the XML but that takes place as soon as the ribbon is loaded rather than hide it based on a conditional thing like if x = 3 then hide the SaveAs tab. Anyone know how to do it via code based on a conditional state?
Thanks
Tuesday, April 2, 2013 3:58 PM
Answers
-
Hi Jim
I believe you'd use the onShow callback that I proposed in an earlier discussion with you. When that triggers, the callback method assiged to onShow would perform the evaluation, set a global variable to store the information (true/false) then call Ribbon.Invalidate to force the Ribbon to run the "get" callbacks.
Your Ribbon XML would also need to include a <tab> element for TabSave with a getVisible attribute to a callback. This callback would check the variable set in onShow and return that value - making the control visible/not visible. (or enabled/not enabled)
See also the article to which I gave you a link before: Customizing the Office 2010 Backstage View for Developers. Look for the sentence "The XML and code work together as follows:"
Cindy Meister, VSTO/Word MVP, my blog
- Proposed as answer by Quist Zhang Thursday, April 4, 2013 1:23 PM
- Marked as answer by Quist Zhang Thursday, April 25, 2013 2:30 AM
Wednesday, April 3, 2013 5:39 PM
All replies
-
Hi Jim
I believe you'd use the onShow callback that I proposed in an earlier discussion with you. When that triggers, the callback method assiged to onShow would perform the evaluation, set a global variable to store the information (true/false) then call Ribbon.Invalidate to force the Ribbon to run the "get" callbacks.
Your Ribbon XML would also need to include a <tab> element for TabSave with a getVisible attribute to a callback. This callback would check the variable set in onShow and return that value - making the control visible/not visible. (or enabled/not enabled)
See also the article to which I gave you a link before: Customizing the Office 2010 Backstage View for Developers. Look for the sentence "The XML and code work together as follows:"
Cindy Meister, VSTO/Word MVP, my blog
- Proposed as answer by Quist Zhang Thursday, April 4, 2013 1:23 PM
- Marked as answer by Quist Zhang Thursday, April 25, 2013 2:30 AM
Wednesday, April 3, 2013 5:39 PM -
Cindy,
The following is section of the XML I am trying to use based on that article you sent. In Viisual Studio the onAction underline informs me "The onAction attribute is not defined" but I didn't define the onAction in the button area just above the tab section. The call back I used for the visible attribute I am told is invalid. In that article you suggested I have not seen examples of how to define an onAction or how to use a callback with an attribute like visible.
Friday, April 5, 2013 9:52 PM -
Hi Jim
You can't assign an onAction to a TAB element. My suggestion didn't involve any onAction, only onShow.
And for dynamic showing/hiding you need the getVisible attribute; visible is static.
Cindy Meister, VSTO/Word MVP, my blog
Saturday, April 6, 2013 11:58 AM -
Cindy,
I was referring to the article information in the section "Performing Actions When the Backstage View is First Displayed or Hidden" which has the sentence "The XML and code work together as follows:" in it. I understand the point of that section but what I am missing is information about what all attributes exist such as getVisible which your reply is the first I have heard of that attribute. Where is such information documented? Also getVisible to me suggests reading current visible value and a setVisible attribute would actually make the tab visible or invisible but I don't have documentation informing me of what is available and how to use. The Word and Excel documents have custom content in them and we make use of custom properties in the Word and Excel templates that identify them as ours. So what I am thinking I need to do in the OnShow backstage event is the following:
OnShow event:
If document is ours then
Hide the standard SaveAs tab
Show our custom SaveAs button (We only need a button)
else
Hide our custom SaveAs button
Show the standard SaveAs Tab
end if
The point of using our SaveAs button is we show a custom SaveAs dialog where we filter the file formats to only two that we allow which is a business requirement. We could use a BeforeSave event which works fine with Word but due to requirements involving our Excel templates BeforeSave doesn't work well because there are so many other products that make use of the BeforeSave event that we cannot control that we are the last BeforeSave event handled. I know 2013 has a afterSave event with Excel but that doesn't appear to help either.
If you have a link to documentation showing the attributes of 2013 and use of callbacks like getVisible please let me know.
Thank you for all the help I do appreciate it. I am just a slow learner.
Jim
Monday, April 8, 2013 2:41 PM -
Hi Jim
Sorry, from the way you posted your questions, I thought you had more background using Ribbon XML and was glossing over things...
The resources can be found on the Custom UI site: http://msdn.microsoft.com/en-us/office/aa905530.aspx
One of the two Backstage articles has a listing of all elements and their attributes.
More information about what the various kinds of callbacks do can be found in the discussion about customizing the Office 2007 Ribbon, a three-part article (further down the website page).
The "get" attributes are those that let you do things dynamically, rather than hard-coding it into the Ribbon XML. There's no "Set", only "get"; the term should be interpreted as "get the information you need to display the control correctly", rather than in the way it's used for defining properties in a class.
Cindy Meister, VSTO/Word MVP, my blog
- Marked as answer by JimBassett Tuesday, April 9, 2013 1:52 PM
- Unmarked as answer by Cindy Meister MVP Saturday, April 13, 2013 7:28 AM
Tuesday, April 9, 2013 6:51 AM -
Cindy,
You don't need to apologize, I am just a slow student. I have a lot of experience developing ribbons for Office 2007 and 2010 but very little experience with modifying or custom development of the backstage. The MSDN backstage examples are usually larger and more complex then just hiding a button, or tab and I learn from small, focused examples and I yet find those. With you various help I think I finally am getting this and have marked this thread as answered. Thank Cindy for all your help!
Tuesday, April 9, 2013 1:57 PM -
Cindy,
The following is the xml for the Backstage. The backstage_show fires, the custom button "CustomSaveAsbtn" appears after the TabSave. The TabSave getVisible callback "GetSaveAsVisible" never gets fired. The custom button onAction event "Custom15FileSaveAs"works. I am trying to base this on the examples that deal with groups and such that are long examples but I am not understanding something. It is very what I am trying to do.
- Edited by JimBassett Tuesday, April 9, 2013 9:36 PM
Tuesday, April 9, 2013 9:35 PM -
Cindy,
From what I am finding out is that I cannot dynamically hide or show a tab like TabSave using a binary addin for Word and Excel which is what I am trying to do. I make use of VSTO addins for the ribbon and for repurpose of standard controls that has worked fine for Word and Excel 2007 and 2010 and still works for Word and Excel 2013 FileSave control because it is still a button. It looks like the getVisible callback is not getting called because it is in an application wide addin and the examples from documentation like http://msdn.microsoft.com/en-us/library/ff645396(v=office.14) is a VBA examples and I am using VB.NET so a subroutine like
Sub GetEngineeringGroupVisibility(control As IRibbonControl, ByRef returnedVal) won't work with VB.NET because one needs to define the type for the arguments. I have tried calling a sub like GetEngineeringGroupVisibility directly from backstage_show but that fails because of casting issues involving the first argument in the sub. That is one of the things that is irritating about those examples they are VBA based and there is enough difference between VBA and VB.NET that is a challenge trying to make this work. We have over a 1000 Word and Excel templates so VBA is not going to be practical especially since our templates must work with 2007, 2010, and 2013 and right our addins work fine with 2007 and 2010.
Wednesday, April 10, 2013 2:43 PM -
The following error message suggests that callbacks cannot be used with build in Tabs
Wednesday, April 10, 2013 7:34 PM -
Hi Jim
Sorry it's taken me so long to get back to you on this. I needed to find a block of time I could devote to setting up a test project and trying a couple of things.
This was a new wrinkle for me, that built-in Tabs couldn't respond to dynamic callbacks.
In that case, the only possibility I see would be to statically (in the XML) make the built-in tab invisible and create your own. You should be able to re-use the Groups provided in the built-in tab so that it basically looks and responds the same way...
Cindy Meister, VSTO/Word MVP, my blog
Saturday, April 13, 2013 7:29 AM -
Hello Jim,
It sounds to me like you just need something in your AutoOpen and/or AutoNew macros. A while back I downloaded an played with the code on this to activate a custom tab that we created on the ribbon. You may be able to use it to hide the tab also.
Hope this helps,
Kenhttp://www.wordarticles.com/Shorts/RibbonVBA/RibbonVBADemo.php
- Edited by KenKrugh Sunday, April 14, 2013 9:21 PM
Sunday, April 14, 2013 9:14 PM -
Thanks Cindy. We have thousands of Excel and Word templates including existing templates scatter over thousands of machines and we use Binary addins (VSTO 4). VBA and XML that has to be in the document is not going to fit our requirements. Our binary addins have worked fine with Office 2007 and 2010 and making the SaveAs a tab without ways to repurpose it or callsback sounds like a design mistake to me.Monday, April 15, 2013 9:12 PM
-
Ken,
Thanks and like replied back to Cindy we make use of VSTO 4 binary addins that work with thousands of Excel and Word templates including existing templates scatter over thousands of machines. Our binary addins have worked fine with Office 2007 and 2010 and making the SaveAs a tab without ways to repurpose it or callsback appears to me to be a big design mistake with Word and Excel 2013.
Monday, April 15, 2013 9:15 PM -
In that case, the only possibility I see would be to statically (in the XML) make the built-in tab invisible and create your own. You should be able to re-use the Groups provided in the built-in tab so that it basically looks and responds the same way...
Cindy Meister, VSTO/Word MVP
This appears to still be an issue today - I ran into this trying to setup backstage callbacks and they all failed as described here and confirmed by displaying interface errors in the options that the callbacks were not being executed.
I've statically set all the built-in backstage elements to visible=false but now I'm at the point of replicating the backstage view so I can assign my callbacks to it.
Has anyone done the backstage replication though? If so, the RibbonX would be greatly appreciated.Or, is there a way to access the default excel RibbonX to use as template?
- Edited by Daniel C. Matthews Friday, May 4, 2018 7:37 PM typo
Friday, May 4, 2018 7:36 PM