At times, you might want to simply extend the actions of an existing recognizer in Office. For example, you might want to add the ability to look up a user 's manager in Active Directory by adding your own action, called Lookup Manager, to the Person Names smart tag included with Office. Extending a smart tag's action list is easy. All you have to do is create a new action DLL. You don't need to create a new recognizer because the recognizer already exists. In your action DLL, you indicate that your action handles only smart tags of type urn:schemas-microsoft-com:office:smarttags#PersonName , which is the type emitted by the Person Names recognizer. Table 9-6 lists the smart tag types for the recognizers included with Office.
Smart Tag Type | Value |
---|---|
Person | urn:schemas-microsoft-com:office:smarttags#PersonName |
Stock Ticker Symbol | urn:schemas-microsoft-com:office:smarttags# stockticker |
Address | urn:schemas-microsoft-com:office:smarttags#address |
Date | urn:schemas-microsoft-com:office:smarttags#date |
Place | urn:schemas-microsoft-com:office:smarttags#place |
Phone Number | urn:schemas-microsoft-com:office:smarttags#phone |
Time | urn:schemas-microsoft-com:office:smarttags#time |
The following code implements a skeleton for extending the Person Names recognizer with new actions:
Implements ISmartTagAction Private Property Get ISmartTagAction_ProgId() As String 'Create a language-independent unique identifier for this 'action that corresponds to the ProgID of this DLL. ISmartTagAction_ProgId = "Extends.PersonNames" End Property Private Property Get ISmartTagAction_Name( _ ByVal LocaleID As Long) As String 'Add a short phrase that describes this action provider DLL. ISmartTagAction_Name = "Extension to Person Names" End Property Private Property Get ISmartTagAction_Desc( _ ByVal LocaleID As Long) As String 'Create a longer description of this recognizer. ISmartTagAction_Desc = "Provides actions for recognized names" End Property Private Property Get ISmartTagAction_SmartTagCount() As Long 'How many smart tag types will this recognizer recognize? '1 in this case. ISmartTagAction_SmartTagCount = 1 End Property Private Property Get ISmartTagAction_SmartTagName( _ ByVal SmartTagID As Long) As String If (SmartTagID = 1) Then ISmartTagAction_SmartTagName = _ "urn:schemas-microsoft-com:office:smarttags#PersonName" End If End Property Private Property Get ISmartTagAction_SmartTagCaption( _ ByVal SmartTagID As Long, _ ByVal LocaleID As Long) As String 'Action DLLs specify the caption for smart tags. ISmartTagAction_SmartTagCaption = "Custom Action" End Property Private Property Get ISmartTagAction_VerbCount( _ ByVal SmartTagName As String) As Long 'For a given smart tag type, how many verbs do we support? If (SmartTagName = _ "urn:schemas-microsoft-com:office:smarttags#PersonName") Then ISmartTagAction_VerbCount = 1 End If End Property Private Property Get ISmartTagAction_VerbID( _ ByVal SmartTagName As String, _ ByVal VerbIndex As Long) As Long If (SmartTagName = _ "urn:schemas-microsoft-com:office:smarttags#PersonName") Then ISmartTagAction_VerbID = VerbIndex End If End Property Private Property Get ISmartTagAction_VerbCaptionFromID( _ ByVal VerbID As Long, _ ByVal ApplicationName As String, _ ByVal LocaleID As Long) As String Select Case VerbID Case 1 ISmartTagAction_VerbCaptionFromID = "Custom Action" End Select End Property Private Property Get ISmartTagAction_VerbNameFromID( _ ByVal VerbID As Long) As String Select Case VerbID Case 1 ISmartTagAction_VerbNameFromID = "CustomAction" End Select End Property Public Sub ISmartTagAction_InvokeVerb( ByVal VerbID As Long, _ ByVal ApplicationName As String, ByVal Target As Object, _ ByVal Properties As SmartTagLib.ISmartTagProperties, _ ByVal Text As String, ByVal XML As String) Select Case VerbID Case 1 'Implement functionality here End Select End Sub