PDA

View Full Version : [SOLVED] Questions from a customUI newbie



Cosmo
10-03-2013, 01:13 PM
I just started to work with a custom UI for my Word document, and I have a few questions.

I was able to set up a quick test that worked to remove all of the tabs and create a custom tab using 'ribbon startFromScratch="true"', but the Table tools content tabs (Design/Layout) still show up. Is there a way to prevent them from appearing as well?

Is there a way to add a complete group from the original ribbon? I tried adding the 'GroupZoom' to my custom tab in the xml, but it just added a blank group.

I tried opening my document on a Mac, but it didn't alter the ribbon. Is the customUI a Windows only functionalit, or is there something different that has to be done for a Mac? The program I have created is intended for PCs, but if I need to make it available to Macs, I would like to know what options I have (if any).

Are there any options in the xml to show/hide or enable/disable elements based on any conditionals? (e.g. software version, platform, macro-enabled status). I believe that I can use VBA to make further changes to the ribbon, but can this be done from the xml code as well?

Are there any good thorough tutorials that anyone can suggest?

Aflatoon
10-04-2013, 03:14 AM
You cannot alter the Mac ribbon, nor can you use conditionals in the XML - you have to use callbacks.
I'm not sure about the contextual tabs and startFromScratch.

Edit: have a read of this page: http://msdn.microsoft.com/en-us/library/office/ee633442%28v=office.11%29.aspx#odc_office2007_DisplayHideRibbonControls_Set tingVisibilityContextualTabs

For general Ribbon information, it is worth reading Ron de Bruin's Ribbon/QAT pages here: http://www.rondebruin.nl/win/section2.htm

Cosmo
10-04-2013, 06:29 AM
You cannot alter the Mac ribbon, nor can you use conditionals in the XML - you have to use callbacks.
I'm not sure about the contextual tabs and startFromScratch.

Edit: have a read of this page: http://msdn.microsoft.com/en-us/library/office/ee633442%28v=office.11%29.aspx#odc_office2007_DisplayHideRibbonControls_Set tingVisibilityContextualTabs
Cool, a quick glance looks like that is what I am looking for. Thanks.


For general Ribbon information, it is worth reading Ron de Bruin's Ribbon/QAT pages here: http://www.rondebruin.nl/win/section2.htm
Thanks for the link, I'll check that out later when I have time.

Another question: Is there a non-VBA way to display a dialog when one of my custom buttons is clicked? The user needs to allow macros to use my document, and if their security setting is set to disable all macros, I'd like to be able to give them an alert. I have doubts that this could be done within the xml, so alternately I may set a custom group that displays text alerting them to check their settings, along with a button to open the Macro Security settings.

Aflatoon
10-04-2013, 06:41 AM
Without VBA you can only use the built-in buttons, I'm afraid.

Cosmo
10-04-2013, 07:26 AM
Without VBA you can only use the built-in buttons, I'm afraid.
Ok, thanks.

I was able to get the contextual tabs hidden using the following:

<contextualTabs>
<tabSet idMso="TabSetSmartArtTools" visible="false"/>
<tabSet idMso="TabSetChartTools" visible="false"/>
<tabSet idMso="TabSetTextBoxTools" visible="false"/>
<tabSet idMso="TabSetWordArtTools" visible="false"/>
<tabSet idMso="TabSetDiagramTools" visible="false"/>
<tabSet idMso="TabSetOrganizationChartTools" visible="false"/>
<tabSet idMso="TabSetPictureTools" visible="false"/>
<tabSet idMso="TabSetPictureToolsClassic" visible="false"/>
<tabSet idMso="TabSetTableTools" visible="false"/>
<tabSet idMso="TabSetHeaderAndFooterTools" visible="false"/>
<tabSet idMso="TabSetEquationTools" visible="false"/>
<tabSet idMso="TabSetInkTools" visible="false"/>
</contextualTabs>

I appreciate all the help, thanks!

Aflatoon
10-04-2013, 09:08 AM
You're welcome. :)

Cosmo
10-04-2013, 02:48 PM
One last question: From what I've been reading, there's no way to access the ribbon controls directly through VBA, only through callbacks (e.g. getVisible="MyMacroName"). I was originally hoping I could show a warning (using a labelControl) to alert the user that the macros were not enabled, but if the getVisible callback doesn't run, it's value is automatically false, and the control doesn't appear. Is there a way to do a boolean inverse (I tried getVisible !="MyMacroName", but of course that wouldn't work), or to otherwise set the value to the opposite of the callback value? I am beginning to think that this is not possible; at best, I could only enable/show a contro when the macros are enabled. The same would be true for using 'getLabel' to set the label's caption.

Aflatoon
10-07-2013, 12:28 AM
It is possible to access the ribbon through VBA using the accessibility objects interface but it's pretty convoluted and if VBA is disabled anyway, that's not really going to help you. ;)

If you're using Excel there's an article in the KB here about prompting users to enable macros, but I don't know how you enforce it in other applications.

Cosmo
10-08-2013, 05:33 AM
It is possible to access the ribbon through VBA using the accessibility objects interface but it's pretty convoluted and if VBA is disabled anyway, that's not really going to help you. ;)

Thanks, I'll look into that. It may do what I need (assUming I can access a specific ribbon element directly through a VBA macro), the issue is that I want to display a label when the macros are disabled. I cannot use the getVisible callbacks (since the value will be false when the macros are disabled, I could only set the visiblity true when they are enabled). If I could either make them invisible, or set their label to an empty string, through a macro, this may do what I need.


If you're using Excel there's an article in the KB here about prompting users to enable macros, but I don't know how you enforce it in other applications.
I'll check around to see if there's any other discussion of enforcing macros for Word.

Thanks again for all of your help.


Edit: 'convoluted' was a pretty accurate description. I found a demo which will select a specific element on the ribbon, and run it's action, but I'm having a hard time determining if it's possible to change their visibility or text, and if so, how to do it.

Aflatoon
10-08-2013, 06:21 AM
I want to display a label when the macros are disabled...If I could either make them invisible, or set their label to an empty string, through a macro

The bold part is the issue I was getting at. ;)

Cosmo
10-08-2013, 07:39 AM
The bold part is the issue I was getting at. ;)Yes, but I'm not trying to set them when the macros are active, I'm trying to remove them:

Add the label control in the xml, set properties to label="Macros are disabled", visibility="True".
Use a macro to make the label invisible or clear their label on startup.
If the macros are disabled, the label isn't set to invisible or cleared, thus is only 'visible' when the macros are disabled.

Aflatoon
10-08-2013, 08:02 AM
Sorry - that was foolish of me. You would require accessibility for that I think or perhaps use the macros to load another document with the real ribbon customisation in it.

Aflatoon
10-08-2013, 11:27 AM
This will give you an idea of the accessibility route: http://www.wordarticles.com/Shorts/RibbonVBA/RibbonVBADemo.php