Share via


Smart Tags Frequently Asked Questions

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

 

Mike Ammerlaan, Jeff Reynar, and Siew-Moi Khor
Microsoft Corporation

July 2001

Applies to:
     Microsoft® Office XP

Summary: This article provides answers to some frequently asked questions about smart tags. (7 printed pages)

The content of this article first appeared in the Microsoft Office XP Smart Tag SDK, which is available for download at the Office Developer Center at MSDN Online.

Contents

Q: Registration: Should I register the smart tag DLLs using their CLSIDs or ProgIDs?
Q: When I turn off my recognizer in Microsoft Word or Microsoft Excel and reboot the application, why is it turned on again? Q: I have built my smart tag DLL using the sample code from the Smart Tag SDK, but it does not work! Why is that? Q: I have looked at all the options in the previous question but it still does not work. What can I try now to debug my DLL? Q: Why do I sometimes see question marks in the text being passed to my recognizer from Word? Q: How do I create actions that work against those that are packaged into Office XP? Q: How do I create a snazzy Web install to deploy the DLLs?

Q: Registration: Should I register the smart tag DLLs using their CLSIDs or ProgIDs?

A: The disabled/enabled state of DLLs registered using their ProgIDs is not preserved across application sessions, as users might expect. (Users can set the disabled/enabled state of smart tag recognizers from the recognizer list on the Smart Tags tab of the AutoCorrect Options dialog box, which is accessible from the Tools menu.) However, the disabled/enabled state of DLLs registered using their CLSIDs is preserved across application sessions. For this reason, it is recommended that smart tag recognizers and action handlers be registered using their CLSIDs rather than their ProgIDs. To learn how to register smart tag DLLs using their CLSIDs, see the Register the Simple Term DLL topic, under the Visual Basic® Tutorial: Creating a List Recognizer and Action topic, in the Microsoft Office XP Smart Tag SDK.

Q: When I turn off my recognizer in Microsoft Word or Microsoft Excel and reboot the application, why is it turned on again?

A: See the previous question.

Q: I have built my smart tag DLL using the sample code from the Smart Tag SDK, but it does not work! Why is that?

A: The first step is to make sure that Microsoft Word or Microsoft Excel is loading your recognizer. Go to the Smart Tags tab of the AutoCorrect Options dialog box (Tools menu) to see if the name of your recognizer is listed along with the other recognizers. If it is not, here are the possible reasons, listed in the order of causal likelihood:

  • Unsigned smart tag DLLs won't run if your security level is set to High, with the Trust all installed add-insand templates check box cleared. At this security setting, all unsigned smart tag DLLs are disabled automatically. To run an unsigned smart tag DLL, the security settings in the Security dialog box (Tools menu, Macro submenu, Security command) must be set to Medium, with the Trust all installed add-insand templates check box cleared. It is strongly recommended that you do this only in a testing environment. After you are done testing, set the security level back to High.

    Caution   By setting the security level to Medium, with the Trust all installed add-ins and templates check box cleared, users will have the choice to either enable or disable unsigned smart tag DLLs when they are prompted. If your security level is set to High, with the Trust all installed add-ins and templates check box cleared, all unsigned smart tag DLLs will be disabled automatically. Therefore, it is strongly recommended that all users keep their security levels set to High with the Trust all installed add-ins and templates check box cleared.

    Security settings are on a per-application basis; therefore, you would need to check this in both Word and Excel. Note that the Trust all installed add-ins and templates box is checked by default in most applications, so in general, unsigned smart tag DLLs should run on most computers. Also, see the white paper entitled "Smart Tag Installation and Security for Microsoft Office XP," included as part of the Smart Tag SDK, for more detail.

  • You did not close and reboot the applications after compiling.
    As long as one copy of Word or Excel or Microsoft® Outlook (with WordMail as the default mail editor) is open, there is the potential that the smart tag registry is not rechecked by these applications when booting new instances of any of these applications. The best solution is to go to your Task Manager (CTRL+ALT+DEL), click the Processes tab, and end all of the OUTLOOK.EXE, WINWORD.EXE, and EXCEL.EXE processes that you see. There is also an off-chance that smart tags are being used by Microsoft Internet Explorer if you have navigated to a page with smart tags on it (especially if you are using MSN® Smart Tags), so you may want to end IEXPLORE.EXE processes as well.

  • One of your smart tag DLLs crashed during a critical point (for example, during booting) for Word or Excel and was disabled.
    To check to see if your smart tag DLL is disabled, look at the registration location in your registry at HKCU\Software\Microsoft\Office\Common\Smart Tag\Recognizers\{your Smart Tag CLSID}. If a Status subkey is placed there, look at the value for the key. 

    • If it is set to 1 bit, the DLL has crashed and been disabled. 
    • If 8 bit is set, the DLL has been disabled in Word.
    • If the 16 bit is set, the DLL is disabled in Excel. 

    Try removing the Status subkey and see what happens. Does your DLL work now? Does it fail to load, and the Status subkey returns? If the latter occurs, something is probably not right with your DLL. Also, see the topic Disabling Individual Smart Tag DLLs in the Smart Tag SDK for more detail.

Note   Modifying the Microsoft Windows registry in any manner, whether through the Registry Editor or programmatically, always carries some degree of risk. Incorrect modification can cause serious problems that may require you to reinstall your operating system. It is a good practice to always back up a computer's registry first before modifying it. If you are running Microsoft Windows NT or Microsoft Windows 2000, you should also update your Emergency Repair Disk (ERD). For information about how to edit the registry, view the "Changing Keys and Values" Help topic in the Registry Editor (Regedit.exe) or the "Add and Delete Information in the Registry" and "Edit Registry Information" topics in the Registry Editor (Regedt32.exe).

  • The DLL's CLSID has changed, and therefore your registration is now inaccurate.
    There is the possibility that your DLL's UUID might have changed. In Microsoft Visual Basic, the UUID's generation is determined by your project's compatibility settings. If the Version Compatibility option on the Component tab of the Properties submenu (Project menu) is set to No Compatibility, a new CLSID is generated every time you compile. This will lead quickly to your smart tag registration no longer being correct. For the CLSID to remain the same every time you recompile, set it to Project Compatibility or Binary Compatibility. Update your smart tag registration accordingly.
  • Your DLL is not registered properly.
    Either recompile or regsvr32 your DLL. To regsvr32 a DLL, click Run on the Start menu. As an example, for the SimpleTerm.dll type "regsvr32 c:\SimpleTerm\SimpleTerm.dll" in the Open box of the Run dialog box. Better still, ensure a clean registration by running "regsvr32 /u <old path\my dll>", copy it to a new location, and run "regsvr32 <new path\my dll>". For example, "regsvr32 /u c:\SimpleTerm\SimpleTerm.dll". If the new location is "c:\NewPath\SimpleTerm2.dll" then run "regsvr32 c:\SimpleTerm\SimpleTerm2.dll". Note that this registers your DLL in the HKEY_CLASSES_ROOT\{your smart tag ProgID}\Clsid hive. You would still need to register your DLL in the HKEY_CURRENT_USER\Software\Microsoft\Office\Common\Smart Tag\{your smart tag CLSID} hive. See the Register the Simple Term DLL topic, under the Visual Basic Tutorial: Creating a List Recognizer and Action topic in the Smart Tag SDK on how to do this.

Q: I have looked at all the options in the previous question but it still does not work. What can I try now to debug my DLL?

A: Try performing recognition and showing actions in both Word and Excel to see if there are any differences between the applications. If certain DLLs work in one application but not the other, check the first three options in the previous question ("...security settings...", "...close and reboot...", and "...DLLs crashed...") again. Also, see the next point for another suggestion as to why this might be happening.

Maybe your recognizer is working but your action DLL is not. If nothing registers actions against a certain smart tag type, and there is no DownloadURL specified, then the Smart Tag Actions button will not show up. To verify this hypothesis, start Word. Type in some terms you know should be recognized by your DLL. Go into the Visual Basic Editor (ALT+F11). In the Immediate window, type "for each st in activedocument.SmartTags: debug.Print st.name: next" and press ENTER. Do you see your smart tag type for those terms you typed in Word listed? If so, recognition is working fine but there is something wrong with your action DLL.

Set breakpoints starting with the Class_Initialize method in Visual Basic, and see if your DLL is being called into. If it is, perhaps you might find that your DLL is silently failing somewhere.

If that fails, try at least adding some message boxes (MsgBoxes) in your DLL and then do a full compile, to ensure your DLL is being called into.

Try running the Action Tool included with the Smart Tag SDK. Is your action DLL listed in that tool? If not, there might be a registration problem; see the fourth option in the previous question above. If your DLL is listed, it might be a security problem; see the first option in the previous question above ("The security settings are too restrictive"), or perhaps your recognizer is not working.

Try adding your smart tag manually in VBA to see what happens and if your action DLL is working. Start Excel. Select cell A1. Enter in some text. Leave cell A1 selected. Press Alt+F11. Type "Selection.SmartTags.Add {my smart tag type}" into the Immediate window, and press ENTER. Go back to Excel. Are your smart tag actions there? If so, your smart tag actions are working fine but perhaps your smart tag recognizer is malfunctioning.

Q: Why do I sometimes see question marks in the text being passed to my recognizer from Word?

A: When a user types in Word, Word creates a buffer into which the users' typing will go. This process improves performance by preventing Word from repeatedly doing memory allocation. The empty portion of this buffer is filled with characters (the Unicode value FFFC, which is the object replacement character). The characters print as question marks, but they also indicate that there is empty space left in the buffer. Your recognizer can ignore those characters. The same character is used in the middle of a string that contains an object that is not itself a character, such as an image or OLE object. This code snippet eliminates these characters from the end of the string Text and replaces those in the middle with spaces, which makes tokenizing the text easier:

Dim position as Integer
Dim Length as Integer

' Check for characters used in word to mark empty space in the
' buffer. If any of those characters are present at the end
' of Text, then eliminate them.
    length = Len(Text)
    If (length > 0) Then
        position = InStr(1, Text, ChrW(-4))
    Else
        position = 0
    End If
    
    While (length > 0 And position > 0)
        Mid$(Text, position, 1) = " "
        length = length - 1
        If (length > 0) Then
            position = InStr(1, Text, ChrW(-4))
        Else
            position = 0
        End If
        position = InStr(1, Text, ChrW(-4))
    Wend
    Text = RTrim(Text)

position = InStr(1, Text, ChrW(-4))
If (position > 0) Then
    length = Len(Text)
    Mid$(Text, position, (length - position + 1)) = 
      Space$(length - position + 1)
    Text = RTrim(Text)
End If

You might be tempted to optimize for performance by using a code snippet like the one below so that your recognizer only runs when the user has finished editing a paragraph. However, a recognizer that attempts to do this will miss the opportunity to smart tag some text, since edit operations in Word that remove the object replacement characters from the end of a string do not cause the text to be passed to the recognizers again.

Dim position as Integer
Dim Length as Integer

position = InStr(1, Text, ChrW(-4))
If (position > 0) Then
    exit sub
End If

Q: How do I create actions that work against those that are packaged into Office XP?

A: Writing actions that work against the types recognized by Office's recognizers (for example, the grammar checker and the stock ticker symbol recognizer) is fairly straightforward. Users need only to register their actions against the following smart tag types:

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

There are other labels that the Office grammar checker recognizer provides, like last name and first name. These can be discovered by turning on the grammar checker recognizer, typing in some names, then going into VBA (ALT+F11). You can query to find out what types are being used by typing the following in the Immediate window:

for each st in ActiveDocument.SmartTags: debug.print st.Name: next st

Q: How do I create a snazzy Web install to deploy the DLLs?

A: This process involves many steps. Essentially, you need to create a Web-based ActiveX® control (OCX). This OCX is packaged with your smart tag DLLs and is also downloadable via Internet Explorer's CAB mechanism such that when it is downloaded your smart tag DLLs are installed as a byproduct. This OCX therefore serves the following roles:

  • It forces the install of a complete package containing the OCX and your smart tag DLLs.
  • It writes the registration keys for your DLLs.
  • It provides a visual indication when your install is complete.

Code signing of .ocx files is covered in the the Internet Component Download topic under the Deployment/Distribution topic in the Smart Tag SDK.