get(ting de)Pressed...

C

Cooz

Hi everyone,

I've made some customizations to the Word 2007 ribbon - among other things I
have supplied a check box in a group on a custom tab that the user may check
if (s)he wants certain additional functionality enabled.

The onAction callback nicely records the state of the checkbox and stores it
for the current user in an .ini file. An add-in queries this value at startup
and takes appropriate actions. What still doesn't work, however, is having
the checkbox reflect the user's choice when Word starts up - it is always
empty.

The customization xml contains the following:
<checkBox id="chkSCPTab" label="Show options at startup"
getPressed="modRibbon.RetrieveChkSCP" onAction="modRibbon.StoreChkSCP" />

The relevant VBA code snippet:
Sub StoreChkSCP(ByVal control As IRibbonControl, ByRef pressed As Boolean)
System.PrivateProfileString("C:\myIni.ini", "Startup", "ShowOptions") =
Format(pressed)
End Sub
Sub RetrieveChkSCP(ByVal control As IRibbonControl, ByRef pressed As Boolean)
pressed = System.PrivateProfileString("C:\myIni.ini", "Startup",
"ShowOptions")
myRibbon.InvalidateControl control.ID
End Sub

StoreChkSCP gets executed just fine each time I click the checkbox.
RetrieveChkSCP doesn't seem to do anything: starting Word and clicking the
tab that contains the checkbox even coughs up a Type mismatch error. Now why
is that? How can I get the value from the .ini file back in the check box?

Thank you,
Cooz
 
C

Cooz

I still get the Type mismatch when I enclose the "System..." within the CBool
function:

Sub RetrieveChkSCP(ByVal control As IRibbonControl, ByRef pressed As Boolean)
pressed = CBool(System.PrivateProfileString("C:\myIni.ini", "Startup",
"ShowOptions"))
myRibbon.InvalidateControl control.ID
End Sub
 
C

Cooz

What works, is

Sub RetrieveChkSCP(ByVal control As IRibbonControl, pressed)
pressed = CBool(System.PrivateProfileString("C:\myIni.ini", "Startup",
"ShowOptions"))
End Sub

Why declaring "pressed" as a Boolean in the signature is not allowed, is a
mystery to me - it becomes a boolean on the next line.
 

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