Select the product you need help with
- Internet Explorer
- Windows Phone
- More products
XL2002: How to Automate Smart Tags by Using Visual Basic for Applications
Article ID: 293808 - View products that this article applies to.
This article was previously published under Q293808
In Microsoft Excel, you can use smart tags to quickly take actions on data entered in a workbook. This article contains sample Microsoft Visual Basic for Applications (VBA) code that demonstrates how to automate smart tags.
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.
You can use Visual Basic for Applications to programmatically add smart tags to cells, to use the smart tags' properties, to execute smart tag actions, and to remove smart tags from cells.
Adding a Smart TagThis example adds a smart tag to cell A1 of the active workbook. You do not have to have the Label data with smart tags check box selected for this code to work properly.
NOTE: The code adds the smart tag to the cell even if the tag is not installed on your computer. However, if it is not installed, the only available actions are Remove this Smart Tag and Smart Tag Options.
Executing a Smart Tag ActionAfter you add a smart tag to a cell, either manually or with a VBA procedure, you can execute any of the smart tag actions by using the following code.
NOTE: You can refer to smart tag actions by using their index number (as in this case), or by using the name that the developer of the smart tag defined.
Removing Smart TagsThe following code sample loops through all smart tags attached to cell A1 and removes them.
Setting Smart Tag OptionsYou can also use Visual Basic for Applications to change the smart tag options for the application and for the current workbook:
For additional information about general smart tag functionality and how to create smart tags, click the article numbers below to view the articles in the Microsoft Knowledge Base:
(http://support.microsoft.com/kb/289148/EN-US/ )XL2002: Smart Tag Functionality
(http://support.microsoft.com/kb/287698/EN-US/ )OFFXP: How to Create a Microsoft Office Smart Tag List