Winterfell63
asked on
disable the "save as" button in Powerpoint 2013 using c# addin
I have created an C# addin and, under certain conditions, and I would like to disable the "save as" command on the backstage, either grey the commands out, or remove them completely. Any help much appreciated.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Instead of trying to disable it, you could handle it using the PowerPoint application event PresentationBeforeSave and then cancelling it with user feedback?
ASKER
Hi JSRWikson
Thanks for your speedy reply, and please forgive the "thickie" response here, but I am using VS2012, created the addin using the wizard and I see no Ribbon XML code in my solution. To be honest, I am more used to using MVVM and WPF than creating addins and I did think that this would be a relatively trivial task, however, it seems to elude my simple mind!
Any further advice you can give would, indeed, be most welcome.
Thanks
Thanks for your speedy reply, and please forgive the "thickie" response here, but I am using VS2012, created the addin using the wizard and I see no Ribbon XML code in my solution. To be honest, I am more used to using MVVM and WPF than creating addins and I did think that this would be a relatively trivial task, however, it seems to elude my simple mind!
Any further advice you can give would, indeed, be most welcome.
Thanks
ASKER
Hi Jamie,
I did think of that, it would, however be a counter-intuitive user experience. If all else fails, then I will fall back on this, but for the time being, I will see if there are alternative solutions out there. Life was SO much easier (although uglier) in the world of MFC <sigh>
I did think of that, it would, however be a counter-intuitive user experience. If all else fails, then I will fall back on this, but for the time being, I will see if there are alternative solutions out there. Life was SO much easier (although uglier) in the world of MFC <sigh>
You need to add a ribbon to your VS project. Right click project, add new item, select Office/SharePoint from left pane then choose Ribbon (Visual Designer).
That will get you a ribbon to work with and try JSRWilson's suggestion.
OM Gang
That will get you a ribbon to work with and try JSRWilson's suggestion.
OM Gang
ASKER
Hi OM Gang
I did as you suggested - but still could find no xml so added a ribbon (xml) and modded that. This had no effect on the visibility or functionality of the save as button. Any further clues?
I did as you suggested - but still could find no xml so added a ribbon (xml) and modded that. This had no effect on the visibility or functionality of the save as button. Any further clues?
I'm just wondering what your AddIn does if it doesnt show a ribbon?
The XML I posted definitely works to simply disable and could be modded to selectively disable.
Just open this file which has the XML attached and you should see .
Save-As-is-disabled.pptx
The XML I posted definitely works to simply disable and could be modded to selectively disable.
Just open this file which has the XML attached and you should see .
Save-As-is-disabled.pptx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yep youre right
I was in 2010 where it's different! You would probably want to use getVisible if there are conditions (I haven't tested)
I was in 2010 where it's different! You would probably want to use getVisible if there are conditions (I haven't tested)
ASKER
thanks to both JSRWilson and to jamie Garroch
I will try this when I get back to my dev machine.
Just to put you in the picture with regards to my add in:
It does show a ribbon (but added as a designer type) but the functionality I am trying to implement happens before my ribbon button actually gets used - two different aspects of my addin.
If a powerpoint presentation is created (by automation) with specific words in the slide notes, I need to save the presentation to a specific location and remove the immediately obvious save-as features (such as the save-as button).
I can detect the conditionm but couldn't seem to jump the final hurdle. I will let you know how I get on.
Thanks
Tony
I will try this when I get back to my dev machine.
Just to put you in the picture with regards to my add in:
It does show a ribbon (but added as a designer type) but the functionality I am trying to implement happens before my ribbon button actually gets used - two different aspects of my addin.
If a powerpoint presentation is created (by automation) with specific words in the slide notes, I need to save the presentation to a specific location and remove the immediately obvious save-as features (such as the save-as button).
I can detect the conditionm but couldn't seem to jump the final hurdle. I will let you know how I get on.
Thanks
Tony
ASKER
To JSRWilson and to Jamie Garroch
OK, although I am still having problems, the original question, as asked, has been answered so I am sharing the solution acceptance.
For any readers searching for the same thing:
This results in the fileSaveAs Button not being visible.
I wanted to do the following:
but the SaveAsEnabled function is never called, neither is the <BackStage onShow="OnShow"> ever called.
I guess that my be the subject for another question. So thanks to both of you for your help thus far.
Tony
OK, although I am still having problems, the original question, as asked, has been answered so I am sharing the solution acceptance.
For any readers searching for the same thing:
Visual Studio 2012 Ultimate
Powerpoint 2013
1. Create a new item -> Ribbon(XML) note: NOT Ribbon (Designer)
2. Modify the schema
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
3. Create my button group, button and associated callbacks manually in the XML and cs files
4. Add the following code
<backstage>
<button idMso="FileSaveAs" visible="false"/>
<tab idMso="TabSave" visible="false"/>
</backstage>
This results in the fileSaveAs Button not being visible.
I wanted to do the following:
MyRibbon.xml
<backstage>
<button idMso="FileSaveAs" getVisible="SaveAsEnabled"/>
<tab idMso="TabSave" getVisible="SaveAsEnabled"/>
</backstage>
MyRibbon.cs
private bool saveAsEnabled;
bool SaveAsEnabled (object Obj)
{
return saveAsEnabled;
}
but the SaveAsEnabled function is never called, neither is the <BackStage onShow="OnShow"> ever called.
I guess that my be the subject for another question. So thanks to both of you for your help thus far.
Tony
ASKER
quick, accurate and friendly responses