Events Available for an Action

The Action object exposes two events. The first is the Click event, where you write the code that handles the event when a user clicks an action on a smart tag. You saw examples of this earlier in this section.

The second event is BeforeCaptionShow. This event enables you to change the caption for an action when the user clicks the Smart Tag Action button, before the menu is shown. For example, you might want to vary the caption title that is shown based on the context of the docu-

Figure 9.10. Displaying actions in a cascading menu in a smart tag

ment. The code in Listing 9.10 displays one caption if the current cursor location is within a Word table; otherwise, it displays a different caption.

Listing 9.10. Using the Caption property of an Action object

Private Sub ShowTableProperties_BeforeCaptionShow(ByVal sender _ As Object, ByVal e As Microsoft.Office.Tools. _ Word.ActionEventArgs) Handles _ ShowTableProperties.BeforeCaptionShow

If Globals.ThisDocument.Application.Selection.Information( _ Word.WdInformation.wdWithInTable) Then

ShowTableProperties.Caption = "Show Table Properties"

Else

ShowTableProperties.Caption = _

"Show Table Properties (if cursor is within a table)"

End If End Sub

0 0

Post a comment