Roderick
08-01-2013, 02:37 PM
I'm using Word 2007 and Windows 7.
I've created a custom menu button which shows six items for a user to choose one. Selecting one of the menu items sets the number of Table of Contents (TOC) levels to display in the active document. The default number is six.
So if a user selects, say, the item which reads "3 levels"from the menu control then the appropriate onAction callback changes a CustomDocumentProperty to "3" and the TOC updates to three visible levels.
So far, so good . . .
Now comes the bit where I get stuck: I want to have a check mark appear next to the level selected on the control menu so that the user can see how many levels they have selected whilst all the others in the menu list do not have any graphic showing.
I'm using a general "getImage" attribute for the six buttons in the menu.
This can be shown by posting the relevant XML code below
<!--Sets TOC Levels-->
<menu id="mnuTOCLevels"
imageMso="TableOfContentsGallery"
label="Set TOC Levels"
size="large"
keytip="L"
itemSize="normal">
<menuSeparator id="SepLevels"
title="Select number of levels" />
<button id="SixLevels"
label="6 Levels (Default)"
screentip="Sets the TOC levels"
supertip="Displays six levels in this document's Table of Contents.
This is the default setting for the document."
getImage="mnuTOCLevels_GetImage"
onAction="mnuTOCLevels_OnAction" />
<button id="FiveLevels"
label="5 Levels"
screentip="Sets the TOC levels"
supertip="Displays five levels in this document's Table of Contents."
getImage="mnuTOCLevels_GetImage"
onAction="mnuTOCLevels_OnAction" />
<button id="FourLevels"
label="4 Levels"
screentip="Sets the TOC levels"
supertip="Displays four levels in this document's Table of Contents."
getImage="mnuTOCLevels_GetImage"
onAction="mnuTOCLevels_OnAction" />
<button id="ThreeLevels"
label="3 Levels"
screentip="Sets the TOC levels"
supertip="Displays three levels in this document's Table of Contents."
getImage="mnuTOCLevels_GetImage"
onAction="mnuTOCLevels_OnAction" />
<button id="TwoLevels"
label="2 Levels"
screentip="Sets the TOC levels"
supertip="Displays two levels in this document's Table of Contents."
getImage="mnuTOCLevels_GetImage"
onAction="mnuTOCLevels_OnAction" />
<button id="OneLevels"
label="1 Level"
screentip="Sets the TOC levels"
supertip="Displays one level in this document's Table of Contents."
getImage="mnuTOCLevels_GetImage"
onAction="mnuTOCLevels_OnAction" />
</menu>
Below is the callback routine to set the TOC levels and update the fields in the document. This is working well and with no problems.
'Callback for SixLevels onAction
Sub mnuTOCLevels_OnAction(control As IRibbonControl)
Select Case control.id
'sets the appropriate document property and then updates the fields in the document
Case Is = "SixLevels"
ActiveDocument.CustomDocumentProperties("TOC Levels") = 6
Call UpdateFields
Case Is = "FiveLevels"
ActiveDocument.CustomDocumentProperties("TOC Levels") = 5
Call UpdateFields
Case Is = "FourLevels"
ActiveDocument.CustomDocumentProperties("TOC Levels") = 4
Call UpdateFields
Case Is = "ThreeLevels"
ActiveDocument.CustomDocumentProperties("TOC Levels") = 3
Call UpdateFields
Case Is = "TwoLevels"
ActiveDocument.CustomDocumentProperties("TOC Levels") = 2
Call UpdateFields
Case Is = "OneLevels"
ActiveDocument.CustomDocumentProperties("TOC Levels") = 1
Call UpdateFields
End Select
End Sub
Following is the code for the getImage callback which is giving me the trouble. I want just one check mark to appear next to to the one which matches the saved document property. At the moment I get one checkmark against every item on the menu!
I know what is going wrong but I cannot think of a way to achieve the correct process.
'Callback for SixLevels getImage
Sub mnuTOCLevels_GetImage(control As IRibbonControl, ByRef returnedVal)
Dim oTOCLevels As Integer
'gets the value of TOC Levels custom property
oTOCLevels = ActiveDocument.CustomDocumentProperties("TOC Levels")
Select Case oTOCLevels
Case Is = 6
returnedVal = "AcceptInvitation"
Case Is = 5
returnedVal = "AcceptInvitation"
Case Is = 4
returnedVal = "AcceptInvitation"
Case Is = 3
returnedVal = "AcceptInvitation"
Case Is = 2
returnedVal = "AcceptInvitation"
Case Is = 1
returnedVal = "AcceptInvitation"
End Select
End Sub
I've kicked the code about in the above procedure but without any luck.
Can anyone offer ideas how I can get just one check mark on the correct level and leave all the others blank. please?
Thanks for any help
Roderick
I've created a custom menu button which shows six items for a user to choose one. Selecting one of the menu items sets the number of Table of Contents (TOC) levels to display in the active document. The default number is six.
So if a user selects, say, the item which reads "3 levels"from the menu control then the appropriate onAction callback changes a CustomDocumentProperty to "3" and the TOC updates to three visible levels.
So far, so good . . .
Now comes the bit where I get stuck: I want to have a check mark appear next to the level selected on the control menu so that the user can see how many levels they have selected whilst all the others in the menu list do not have any graphic showing.
I'm using a general "getImage" attribute for the six buttons in the menu.
This can be shown by posting the relevant XML code below
<!--Sets TOC Levels-->
<menu id="mnuTOCLevels"
imageMso="TableOfContentsGallery"
label="Set TOC Levels"
size="large"
keytip="L"
itemSize="normal">
<menuSeparator id="SepLevels"
title="Select number of levels" />
<button id="SixLevels"
label="6 Levels (Default)"
screentip="Sets the TOC levels"
supertip="Displays six levels in this document's Table of Contents.
This is the default setting for the document."
getImage="mnuTOCLevels_GetImage"
onAction="mnuTOCLevels_OnAction" />
<button id="FiveLevels"
label="5 Levels"
screentip="Sets the TOC levels"
supertip="Displays five levels in this document's Table of Contents."
getImage="mnuTOCLevels_GetImage"
onAction="mnuTOCLevels_OnAction" />
<button id="FourLevels"
label="4 Levels"
screentip="Sets the TOC levels"
supertip="Displays four levels in this document's Table of Contents."
getImage="mnuTOCLevels_GetImage"
onAction="mnuTOCLevels_OnAction" />
<button id="ThreeLevels"
label="3 Levels"
screentip="Sets the TOC levels"
supertip="Displays three levels in this document's Table of Contents."
getImage="mnuTOCLevels_GetImage"
onAction="mnuTOCLevels_OnAction" />
<button id="TwoLevels"
label="2 Levels"
screentip="Sets the TOC levels"
supertip="Displays two levels in this document's Table of Contents."
getImage="mnuTOCLevels_GetImage"
onAction="mnuTOCLevels_OnAction" />
<button id="OneLevels"
label="1 Level"
screentip="Sets the TOC levels"
supertip="Displays one level in this document's Table of Contents."
getImage="mnuTOCLevels_GetImage"
onAction="mnuTOCLevels_OnAction" />
</menu>
Below is the callback routine to set the TOC levels and update the fields in the document. This is working well and with no problems.
'Callback for SixLevels onAction
Sub mnuTOCLevels_OnAction(control As IRibbonControl)
Select Case control.id
'sets the appropriate document property and then updates the fields in the document
Case Is = "SixLevels"
ActiveDocument.CustomDocumentProperties("TOC Levels") = 6
Call UpdateFields
Case Is = "FiveLevels"
ActiveDocument.CustomDocumentProperties("TOC Levels") = 5
Call UpdateFields
Case Is = "FourLevels"
ActiveDocument.CustomDocumentProperties("TOC Levels") = 4
Call UpdateFields
Case Is = "ThreeLevels"
ActiveDocument.CustomDocumentProperties("TOC Levels") = 3
Call UpdateFields
Case Is = "TwoLevels"
ActiveDocument.CustomDocumentProperties("TOC Levels") = 2
Call UpdateFields
Case Is = "OneLevels"
ActiveDocument.CustomDocumentProperties("TOC Levels") = 1
Call UpdateFields
End Select
End Sub
Following is the code for the getImage callback which is giving me the trouble. I want just one check mark to appear next to to the one which matches the saved document property. At the moment I get one checkmark against every item on the menu!
I know what is going wrong but I cannot think of a way to achieve the correct process.
'Callback for SixLevels getImage
Sub mnuTOCLevels_GetImage(control As IRibbonControl, ByRef returnedVal)
Dim oTOCLevels As Integer
'gets the value of TOC Levels custom property
oTOCLevels = ActiveDocument.CustomDocumentProperties("TOC Levels")
Select Case oTOCLevels
Case Is = 6
returnedVal = "AcceptInvitation"
Case Is = 5
returnedVal = "AcceptInvitation"
Case Is = 4
returnedVal = "AcceptInvitation"
Case Is = 3
returnedVal = "AcceptInvitation"
Case Is = 2
returnedVal = "AcceptInvitation"
Case Is = 1
returnedVal = "AcceptInvitation"
End Select
End Sub
I've kicked the code about in the above procedure but without any luck.
Can anyone offer ideas how I can get just one check mark on the correct level and leave all the others blank. please?
Thanks for any help
Roderick