Custom Images not showing in Ribbon toggle button

L

Ludo

Hi,

I use the toggle button code from Ron De Bruin's site (http://www.rondebruin.nl/getimage.htm) to change te state of the toggle button and change also the picture in the toggle button.
The problem i have is that the pictures don't show up in the button.
Both pictures are .png and are embedded in the CustomUI.xml file.

here's the code i use (all in the same module):

Dim myRibbon As IRibbonUI
Dim PressedState As Boolean
'*****************************************
'Ribbon callback functions / routines
'*****************************************
'Callback for customUI.onLoad
Sub RibbonLoaded(ribbon As IRibbonUI)
Set myRibbon = ribbon
PressedState = False
End Sub

'Callback for customToggleButton1 onAction
Sub Macro1(control As IRibbonControl, pressed As Boolean)
Select Case pressed
Case True
PressedState = True
Case False
PressedState = False
End Select
myRibbon.InvalidateControl ("customToggleButton1")
End Sub

Sub GetImage(control As IRibbonControl, ByRef image)
Select Case control.ID
Case "customToggleButton1"
Select Case PressedState
Case True: image = "Close-2-icon" 'picture don't show up
Case False: image = "zip-icon" 'picture don't show up
End Select
End Select
End Sub

Sub GetLabel(ByVal control As IRibbonControl, ByRef label)
Select Case control.ID
Case "customToggleButton1"
Select Case PressedState
Case True: label = "Stop Auto Zip"
Case False: label = "Start Auto Zip"
End Select
End Select
End Sub

Any idea why?
I can use those pictures on a normal custom button, but are not showing up in the toggle button.
I tried also to add the file extension (Case True: image = "Close-2-icon.png") but no luck at all.

any help apreciated.
Regards,
Ludo
 
L

Ludo

Op dinsdag 9 oktober 2012 14:33:40 UTC+2 schreef Ludo het volgende:
Hi, I use the toggle button code from Ron De Bruin's site (http://www.rondebruin.nl/getimage.htm) to change te state of the toggle button and changealso the picture in the toggle button. The problem i have is that the pictures don't show up in the button. Both pictures are .png and are embedded in the CustomUI.xml file. here's the code i use (all in the same module): Dim myRibbon As IRibbonUI Dim PressedState As Boolean '***************************************** 'Ribbon callback functions / routines '***************************************** 'Callback for customUI.onLoad Sub RibbonLoaded(ribbon As IRibbonUI) Set myRibbon = ribbon PressedState = False End Sub 'Callback for customToggleButton1 onAction Sub Macro1(control As IRibbonControl, pressed As Boolean) Select Case pressed Case True PressedState = True Case False PressedState = False End Select myRibbon.InvalidateControl ("customToggleButton1") End Sub Sub GetImage(control As IRibbonControl, ByRef image) Select Case control.ID Case "customToggleButton1" Select Case PressedState Case True: image = "Close-2-icon" 'picture don't show up Case False: image = "zip-icon" 'picture don't show up End Select End Select End Sub Sub GetLabel(ByVal control As IRibbonControl, ByRef label) Select Case control.ID Case "customToggleButton1" Select Case PressedState Case True: label = "Stop Auto Zip" Case False: label = "Start Auto Zip" End Select End Select End Sub Any idea why? I can use those pictures on a normal custom button, but are not showing up in the toggle button. I tried also to add the file extension (Case True: image = "Close-2-icon.png") but no luck atall. any help apreciated. Regards, Ludo

Hi,

Just forget this problem.
Found the solution on the same location as mentioned above.
Should have read the whole page.
When reading the text for example 3, i noticed that it's mentioned that youcan't use embedded pictures from the CustomUI.xml file that way. Hope thatMicrosoft will implement this possibility in one or another servicepack. In the mean time, my problem is solved using the code for the thirth example..
Thanks to Ron de Bruin, Stephen Bullen & Rob Bovey for the code.

Regards,
Ludo
 
L

Ludo

Op dinsdag 9 oktober 2012 14:33:40 UTC+2 schreef Ludo het volgende:
<SNIP>

Hi again,

I'm bouncing to a new problem.
As long as the workbook is a .xlsm workbook, everything works fine as supposed to be, but as soon i save & run it as an Add-In (.xlam), clicking the toggle button generates me following error:" Wrong number of arguments on invaled property assignment."

I can't figure out what and where it goes wrong.
There's no breakpoint at the line causing the error, it just bails out withthe error warning.
The only thing i'm pretty sure abouth is that it has to do with the toggle button code. The other 'normal' button works fine.
I moved the original code from the Workbook_Activate event to the Workbook_Open event & the Workbook_Deactivate event to the Workbook_BeforeClose event because the original events (Workbook_Activate & Workbook_Deactivate )are not fired in a Add-In (or a'm i wrong). But even this doesn't solve the problem.

Anyone who can help me solve this problem,
I realy want it to run as an add-in.
If needed, i can send the whole workbook to take a look at it.

thanks in advance.
regards,
Ludo
 

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