Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-21-2018, 07:21 AM
slaycock slaycock is offline RibbonUI: getVisible not working for Custom Tabs Windows 7 64bit RibbonUI: getVisible not working for Custom Tabs Office 2016
Expert
RibbonUI: getVisible not working for Custom Tabs
 
Join Date: Sep 2013
Posts: 256
slaycock is on a distinguished road
Default RibbonUI: getVisible not working for Custom Tabs

I have a template with a customized ribbon. The customizations remove the paragraph and style tabs and rebuild a subset of the paragraph tab. The customization also adds three custom tabs.

If the XML for the CustomUI is written using the Visible attribute rather than getVisible the customized ribbon appears and functions as it is designed to do.

The initialization behind the customization is lengthy so to allow the document to be opened for quick edits there is a separate button which runs the initialization. This means that some buttons in the Custom tabs cause errors as the data structures behind them are not initialized.

To avoid such errors I have changed the visible attribute from 'visible ="true"' to the callback 'getVisible = "get_visible"' in the Custom XML. The callback get _visible simply returns a boolean value (flag) which is false if initialization has not been done and true if it has been done.

The visibility of built in elements is controlled by 'not flag' and customized elements by 'flag' so changing flag from false to true and then invalidating the ribbon should hide the built in elements I want hiding and show the customized elements.



When I load the document everything is correct. No built in elements are hidden and no custom elements are visible.

However, when I run the initialization I end up with an incorrect Ribbon

The built in elements I have set to be hidden are hidden
The subset of the paragraph tab that I want to be visible is visible
The custom tabs I want to be visible are NOT visible.

I can't for the life of me work out why.

The current state of the get_visible code is below. user_customui_activated is the 'flag' variable.

Code:
Sub get_visible(control As IRibbonControl, ByRef returnVal)
   
    Select Case control.ID
         
         Case IDMSO_BULLETS_GALLERY_WORD
             returnVal = Not user_customui_activated
             Debug.Print control.ID, Not user_customui_activated
         Case IDMSO_NUMBERING_GALLERY_WORD
             returnVal = Not user_customui_activated
             Debug.Print control.ID, Not user_customui_activated
         Case IDMSO_MULTI_LEVEL_LIST
             returnVal = Not user_customui_activated
             Debug.Print control.ID, Not user_customui_activated
        Case IDMSO_GROUP_STYLES
             returnVal = Not user_customui_activated
             Debug.Print control.ID, Not user_customui_activated
         Case IDMSO_GROUP_PARAGRAPH
             returnVal = Not user_customui_activated
             Debug.Print control.ID, Not user_customui_activated
             
         Case rbnID_READ_user_CMC
             returnVal = user_customui_activated
             Debug.Print control.ID, user_customui_activated
             
         
         Case rbnID_ARC_PARAGRAPHS
             returnVal = user_customui_activated
             Debug.Print control.ID, user_customui_activated
         Case rbnID_TAB_UTILITIES
             returnValue = user_customui_activated
             Debug.Print control.ID, user_customui_activated
         Case rbnID_TAB_user
             returnValue = user_customui_activated
             Debug.Print control.ID, user_customui_activated
         Case rbnID_TAB_REGULATORY
             returnValue = user_customui_activated
             Debug.Print control.ID, user_customui_activated
         Case Else
                 MsgBox "getVisible called for " & control.ID, vbOKOnly
    
     End Select
End Sub
an example of the xml for an IDMSO and rbnID element are provided below.

Code:
<group 
					idMso="GroupStyles"
					getVisible="get_visible"/>


<tab
				label="Utilities"
				id="Tab_Utilities"
				getVisible="get_visible">
				
				<group 
					label="Style Management"
					id="StyleManagement">
					
					<button
						id="Read_User_CMC_Resources" 
						label="Re-Read Resources" 
						onAction="button_onAction"
						getSupertip = "get_supertip"
						getVisible = "get_visible"/>
						
				</group>
				
			</tab>
Output from the debug statements is

On load

ArcParagraphs False
Tab_Utilities False
Tab_user False
Tab_Regulatory False
GroupParagraph True
GroupStyles True

After initialisation

GroupParagraph False
GroupStyles False
ArcParagraphs True
Tab_Utilities True
Tab_user True
Tab_Regulatory True

Any suggestions as to what to investigate next would be welcome.
Reply With Quote
  #2  
Old 02-21-2018, 07:50 AM
slaycock slaycock is offline RibbonUI: getVisible not working for Custom Tabs Windows 7 64bit RibbonUI: getVisible not working for Custom Tabs Office 2016
Expert
RibbonUI: getVisible not working for Custom Tabs
 
Join Date: Sep 2013
Posts: 256
slaycock is on a distinguished road
Default

Sorry for replying to my own thread,

The solution was in the variable type passed back to returnedVal. Shortly after posting I rmembered that I'd had some previous trouble before with returned values to the RibbonUI that was solved by casting the returned valriable to the variant Type

I changed all assignments to returnedVal to cVar(<expression>) (Cast the boolean to a variant).

Everything worked first time.

Now I have the RibbonX book and I've scoured VBA pages in relation to ribbon stuff and I haven't come across this requirement. So having wasted a day on this you can Imagine I'm pretty cheesed off.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Exporting Custom Ribbons/Tabs koolwaters Word 1 03-21-2014 03:50 PM
Custom Tabs and Groups KHenry Word 0 10-08-2013 09:37 AM
Custom Task sending not working d7jab Outlook 0 10-16-2012 08:51 AM
New/Custom Tabs in Excel 2010 judicial85 Excel 1 09-27-2011 07:59 AM
Creating custom tabs for Word & Excel 2003 on a Windows 7 OS Skarab Office 1 07-05-2010 09:23 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:11 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft