RibbonX - programatically enable/disable buttons

W

Wei Lu [MSFT]

Hello Dave,

When you devlop the custom Ribbon control, you could use the getVisiable
callback in the XML to programmatically determine whether to show or hide a
tab.

You could follow the example in the article:

http://msdn2.microsoft.com/en-us/library/aa338202.aspx#OfficeCustomizingRibb
onUIforDevelopers_Access

Sincerely,

Wei Lu

Microsoft Online Community Support

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
P

Patrick Schmid [MVP]

When you use getVisible, you should keep in mind that even if a control
is invisible, the user can still access it via the QAT Customization
dialog and execute it via the QAT. You should always use the getEnable
callback as well and disable all the controls with it as well. If you
hide a tab, group or menu, keep in mind that you need to disable every
single control individually contained within them.

Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
***
Customize Office 2007: http://pschmid.net/office2007/customize
RibbonCustomizer Add-In: http://pschmid.net/office2007/ribboncustomizer
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed
 
D

David Thielen

Correct - I don't want to make the buttons invisible - I need to disable
them. Is there a way to do that after the Ribbon has been displayed?

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm




Patrick Schmid said:
When you use getVisible, you should keep in mind that even if a control
is invisible, the user can still access it via the QAT Customization
dialog and execute it via the QAT. You should always use the getEnable
callback as well and disable all the controls with it as well. If you
hide a tab, group or menu, keep in mind that you need to disable every
single control individually contained within them.

Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
***
Customize Office 2007: http://pschmid.net/office2007/customize
RibbonCustomizer Add-In: http://pschmid.net/office2007/ribboncustomizer
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed

Hello Dave,

When you devlop the custom Ribbon control, you could use the getVisiable
callback in the XML to programmatically determine whether to show or hide a
tab.

You could follow the example in the article:

http://msdn2.microsoft.com/en-us/library/aa338202.aspx#OfficeCustomizingRibb
onUIforDevelopers_Access

Sincerely,

Wei Lu

Microsoft Online Community Support

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
D

David Thielen

Please correct me if I am wrong but that will be called when the Ribbon is
first shown. But I enable/disable controls based on the position of the caret.

Think of the Cut and Copy buttons - they will enable if text is selected and
disable if no text is selected. I need to be able to do the same thing.

So how can I enable/disable the buttons after my ribbon is displayed? It
must be possible because it happens for the Cut and Copy buttons.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
P

Patrick Schmid [MVP]

You use the getEnabled callback and return whatever state the button has
to be in.
The trick is to tell Office to execute the callback again. To do so, you
need to implement the onLoad callback for customUI. That will give you
an IRibbonUI object. Store that.
When you need to tell Office to execute a callback again, call the
IRibbonUI.InvalidateControl(controlId) method. You can also use
IRibbonUI.Invalidate() to invalidate all controls at once, but I would
highly suggest to use the InvalidateControl method at all times.

Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
***
Customize Office 2007: http://pschmid.net/office2007/customize
RibbonCustomizer Add-In: http://pschmid.net/office2007/ribboncustomizer
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed
 
D

David Thielen

Oh yuck - what a mess. Ok, I'll get to work on this. Thank you.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm




Patrick Schmid said:
You use the getEnabled callback and return whatever state the button has
to be in.
The trick is to tell Office to execute the callback again. To do so, you
need to implement the onLoad callback for customUI. That will give you
an IRibbonUI object. Store that.
When you need to tell Office to execute a callback again, call the
IRibbonUI.InvalidateControl(controlId) method. You can also use
IRibbonUI.Invalidate() to invalidate all controls at once, but I would
highly suggest to use the InvalidateControl method at all times.

Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
***
Customize Office 2007: http://pschmid.net/office2007/customize
RibbonCustomizer Add-In: http://pschmid.net/office2007/ribboncustomizer
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed

Please correct me if I am wrong but that will be called when the Ribbon is
first shown. But I enable/disable controls based on the position of the caret.

Think of the Cut and Copy buttons - they will enable if text is selected and
disable if no text is selected. I need to be able to do the same thing.

So how can I enable/disable the buttons after my ribbon is displayed? It
must be possible because it happens for the Cut and Copy buttons.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
D

David Thielen

Implemented and works great. Thank you.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm




Patrick Schmid said:
You use the getEnabled callback and return whatever state the button has
to be in.
The trick is to tell Office to execute the callback again. To do so, you
need to implement the onLoad callback for customUI. That will give you
an IRibbonUI object. Store that.
When you need to tell Office to execute a callback again, call the
IRibbonUI.InvalidateControl(controlId) method. You can also use
IRibbonUI.Invalidate() to invalidate all controls at once, but I would
highly suggest to use the InvalidateControl method at all times.

Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
***
Customize Office 2007: http://pschmid.net/office2007/customize
RibbonCustomizer Add-In: http://pschmid.net/office2007/ribboncustomizer
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed

Please correct me if I am wrong but that will be called when the Ribbon is
first shown. But I enable/disable controls based on the position of the caret.

Think of the Cut and Copy buttons - they will enable if text is selected and
disable if no text is selected. I need to be able to do the same thing.

So how can I enable/disable the buttons after my ribbon is displayed? It
must be possible because it happens for the Cut and Copy buttons.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top