Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Unable to change "Enabled" state of an Excel 2007 ribbon gallery b

Hi folks, Looking for help on this.
If we embed a button inside an excel 2007 ribbon gallery, it is not possible
to change its "Enabled" state after a workbook is opened and the gallery is
expanded. Only on workbook open the "getEnabled" callback is successfully
executed and the proper state is achieved. Following workbook open as well,
before the gallery is expanded, the state changes successfully. However once
the gallery is expanded the state cannot be changed.

Buttons that are not embedded in a gallery work just fine.

can be definitely seen on SP0 and SP2.

the xml file to customize the
ribbon:---------------------------------------------------------------------------------------------------------------

<!--
Here we have added a button and a gallery containing a button in the Home
tab of the excel ribbon.
We have grouped them under the "Enable Issue" group.
The two buttons "Will Change" and "Won't Change" both have the same
callback corresponding to the "getEnabled" property.
--

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

<ribbon

<tabs

<tab idMso="TabHome"

<group id="RDBGroup2" label="Enable Issue"

<gallery id="IssueGallery" imageMso="DateAndTimeInsert"

label="Expand Me" columns="3" rows="4" onAction="InsertMonth"

<button id="Disobedient" label="Won't Change"
getEnabled="GetEnabled" /

</gallery

<button id="Obedient" label="Will Change"
getEnabled="GetEnabled" /



</group

</tab
</tabs
</ribbon

</customUI

The VBA code that calls ribbon.invalidate

Option Explicit

Dim Rib As IRibbonUI
Public Enabled As Boolean

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

Sub GetEnabled(control As IRibbonControl, ByRef returnedVal)
returnedVal = Enabled
End Sub
Sub Set_Enabled()
Enabled = True
Rib.Invalidate
End Sub
Sub Set_Disabled()
Enabled = False
Rib.Invalidate
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,489
Default Unable to change "Enabled" state of an Excel 2007 ribbon galleryb

Hi,

Not sure I follow. You can change the state of the button within the
gallery by using the Invalidate method you have in your code.
But what I can not see is what you think should be causing the
Set_Enabled or Set_Disabled routines to run.

I added a routine which you had assigned to the galleries OnAction.
You will need to add an item to the gallery in order to raise the callback.

'---------
Public Sub InsertMonth(control As IRibbonControl, selectedId As String,
selectedIndex As Integer)
'
' Code for onAction callback. Ribbon control gallery
'
If Enabled Then
Set_Disabled
Else
Set_Enabled
End If

End Sub
'---------

The button in the gallery and on the ribbon will now alternate state.

Cheers
Andy

On 19/03/2010 10:13, basso profondo wrote:
Hi folks, Looking for help on this.
If we embed a button inside an excel 2007 ribbon gallery, it is not possible
to change its "Enabled" state after a workbook is opened and the gallery is
expanded. Only on workbook open the "getEnabled" callback is successfully
executed and the proper state is achieved. Following workbook open as well,
before the gallery is expanded, the state changes successfully. However once
the gallery is expanded the state cannot be changed.

Buttons that are not embedded in a gallery work just fine.

can be definitely seen on SP0 and SP2.

the xml file to customize the
ribbon:---------------------------------------------------------------------------------------------------------------

<!--
Here we have added a button and a gallery containing a button in the Home
tab of the excel ribbon.
We have grouped them under the "Enable Issue" group.
The two buttons "Will Change" and "Won't Change" both have the same
callback corresponding to the "getEnabled" property.
--

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

<ribbon

<tabs

<tab idMso="TabHome"

<group id="RDBGroup2" label="Enable Issue"

<gallery id="IssueGallery" imageMso="DateAndTimeInsert"

label="Expand Me" columns="3" rows="4" onAction="InsertMonth"

<button id="Disobedient" label="Won't Change"
getEnabled="GetEnabled" /

</gallery

<button id="Obedient" label="Will Change"
getEnabled="GetEnabled" /



</group

</tab
</tabs
</ribbon

</customUI

The VBA code that calls ribbon.invalidate

Option Explicit

Dim Rib As IRibbonUI
Public Enabled As Boolean

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

Sub GetEnabled(control As IRibbonControl, ByRef returnedVal)
returnedVal = Enabled
End Sub
Sub Set_Enabled()
Enabled = True
Rib.Invalidate
End Sub
Sub Set_Disabled()
Enabled = False
Rib.Invalidate
End Sub


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Unable to change "Enabled" state of an Excel 2007 ribbon galle

Thanks Andy,

I should have mentioned that I am explicitly calling the Set_Enabled and
Get_Enabled macros.
For some reason the onAction callback for the gallery is not getting called
in my case.
From some testing, this is what I deduce on how the getEnabled callbacks are
called for the different buttons.
(1) For the button outside the gallery it gets called when the ribbon is
invalidated (Happens properly on my Excel)
(2) For the button embedded in the gallery it gets called when the gallery
is expanded. In my case the issue seems to be that the callback is called
only on the first expansion of the gallery. It is not called thereafter.
Seems to be a systematic issue.
Also, the gallery onAction callback not being called is a little strange. I
am possibly going wrong somewhere, but I would rather concentrate on (2)
If it is possible could you test it on your side?

Regards.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,489
Default Unable to change "Enabled" state of an Excel 2007 ribbon galle

I will investigate further if you can email an example file. That way I
will not have to guess or make assumptions about what you actually have
setup.

andy AT andypope DOT info

Cheers
Andy

On 23/03/2010 07:04, basso profondo wrote:
Thanks Andy,

I should have mentioned that I am explicitly calling the Set_Enabled and
Get_Enabled macros.
For some reason the onAction callback for the gallery is not getting called
in my case.
From some testing, this is what I deduce on how the getEnabled callbacks are
called for the different buttons.
(1) For the button outside the gallery it gets called when the ribbon is
invalidated (Happens properly on my Excel)
(2) For the button embedded in the gallery it gets called when the gallery
is expanded. In my case the issue seems to be that the callback is called
only on the first expansion of the gallery. It is not called thereafter.
Seems to be a systematic issue.
Also, the gallery onAction callback not being called is a little strange. I
am possibly going wrong somewhere, but I would rather concentrate on (2)
If it is possible could you test it on your side?

Regards.


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Unable to change "Enabled" state of an Excel 2007 ribbon galle

Thanks Andy,

I have sent a sample workbook to your email.

Regards.

"Andy Pope" wrote:

I will investigate further if you can email an example file. That way I
will not have to guess or make assumptions about what you actually have
setup.

andy AT andypope DOT info

Cheers
Andy

On 23/03/2010 07:04, basso profondo wrote:
Thanks Andy,

I should have mentioned that I am explicitly calling the Set_Enabled and
Get_Enabled macros.
For some reason the onAction callback for the gallery is not getting called
in my case.
From some testing, this is what I deduce on how the getEnabled callbacks are
called for the different buttons.
(1) For the button outside the gallery it gets called when the ribbon is
invalidated (Happens properly on my Excel)
(2) For the button embedded in the gallery it gets called when the gallery
is expanded. In my case the issue seems to be that the callback is called
only on the first expansion of the gallery. It is not called thereafter.
Seems to be a systematic issue.
Also, the gallery onAction callback not being called is a little strange. I
am possibly going wrong somewhere, but I would rather concentrate on (2)
If it is possible could you test it on your side?

Regards.


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info

.

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
Can't find "Visual Basic" Toolbar on Excel 2007 Ribbon [email protected][_2_] Excel Programming 3 February 17th 10 01:06 AM
Excel 2007 ribbon Controls & "My.Settings" equivalent in VBA rogge Excel Programming 0 January 8th 09 11:33 PM
Custom Ribbon example in Walkenbach's "Excel 2007 Power Programming with VBA" Greg Lovern Excel Programming 1 September 16th 07 03:42 PM
Allow user to change the state of ("click" in) check-boxes on protected worksheets? Chuck Zissman Excel Worksheet Functions 2 May 12th 07 08:10 PM
CommandBars("Worksheet Menu Bar").Controls("Tools").Enabled = Fals Arturo Excel Programming 3 May 26th 05 05:44 PM


All times are GMT +1. The time now is 06:54 PM.

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

About Us

"It's about Microsoft Excel"