Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default how can I disable a control in the ribbon at run time

As an example, in Excel 2007, I have 5 buttons on the ribbon. When I press a
button, it runs code and then it is meant to disable the button. Do you know
how I could do this? Any help would be appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default how can I disable a control in the ribbon at run time

Hi irvy

See
http://www.rondebruin.nl/hidevisible.htm

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"irvy" wrote in message ...
As an example, in Excel 2007, I have 5 buttons on the ribbon. When I press a
button, it runs code and then it is meant to disable the button. Do you know
how I could do this? Any help would be appreciated.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default how can I disable a control in the ribbon at run time

Hey Ron,
Thanks for the quick reply. I have checked out your examples. What
they do is actually make the controls invisible. I still want to see
the control but want it disabled. Is that possible?

irvy
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default how can I disable a control in the ribbon at run time

Hi Irvy

You can use getEnabled for a button but not for a group

If you change this in the RibbonX of my example workbook
Hide-Display-Group-Control
You see that it Enable/disable the button instead of hide/unhide it

<button id="customButton5" label="Caption 5" size="large" onAction="Macro5"
imageMso="AccountMenu" getEnabled="GetVisible" tag="MyPersonalControl" /


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Irvy" wrote in message ...
Hey Ron,
Thanks for the quick reply. I have checked out your examples. What
they do is actually make the controls invisible. I still want to see
the control but want it disabled. Is that possible?

irvy

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default how can I disable a control in the ribbon at run time

Hi Ron,

I am still having some problems. I am just testing out the process
before I proceed with my actual code but I am getting this error:

"Runtime 91. Object variable or With block variable not set"

Can you tell me why I am getting this error?

Here is my xml code:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?
<customUI onLoad="RibbonOnLoad" xmlns="http://schemas.microsoft.com/
office/2006/01/customui"
<ribbon
<tabs

<tab idMso="TabHome"

<group id="grp1" label="Group1" tag="MyPersonalGroup"
<button id="btn1" label="button1" size="large"
onAction="disableBtn1" getEnabled="GetEnabled"
imageMso="DirectRepliesTo" /
<button id="btn2" label="button2" size="large"
onAction="disableBtn2" getEnabled="GetEnabled" imageMso="AccountMenu" /

</group

</tab

</tabs
</ribbon
</customUI

and here is my vba code:

Option Explicit
Dim Rib As IRibbonUI

'Callback for customUI.onLoad
Sub RibbonOnLoad(ribbon As IRibbonUI)
Set Rib = ribbon
End Sub

'Callback for btn1 getEnabled
Sub GetEnabled(control As IRibbonControl, ByRef returnedVal)
returnedVal = True
End Sub

'Callback for btn1 onAction
Sub disableBtn1(control As IRibbonControl)
Dim Rib As IRibbonUI
Rib.InvalidateControl ("btn1")
End Sub

'Callback for btn2 onAction
Sub disableBtn2(control As IRibbonControl)
Dim Rib As IRibbonUI
Rib.InvalidateControl ("btn2")
End Sub
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ribbon and toolbar, program control Ken[_28_] Excel Programming 2 October 23rd 09 01:46 PM
Current Document Name From Ribbon Control chris seiter Excel Programming 0 July 24th 09 09:01 PM
How do I Disable My Buttons in a Customized added Ribbon Tab ? Meus Excel Programming 2 February 9th 09 03:17 PM
Disable items on ribbon using VBA Cresta Excel Programming 2 January 21st 09 08:42 AM
Linking a Ribbon control with an help file Ahasverus Excel Programming 3 October 14th 07 08:19 PM


All times are GMT +1. The time now is 05:11 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"