TagString Property (ActiveX)

Specifies the tag string of the object.

Supported platforms: Windows only

Signature

VBA:

object.TagString
object

Type: Attribute, AttributeReference, PopupMenu, PopupMenuItem, Toolbar, ToolbarItem

The objects this property applies to.

Property Value

Read-only: No; except for PopupMenu and Toolbar objects

Type: String

The tag string of the object.

Remarks

Attribute, AttributeReference: This string identifies each occurrence of the attribute. Enter any characters except spaces or exclamation points. AutoCAD changes lowercase letters to uppercase.

PopupMenu, PopupMenuItem, Toolbar, ToolbarItem: A tag, or name tag, is a string consisting of alphanumeric and underscore (_) characters. This string uniquely identifies the item within a given customization file. This string is automatically assigned when the object is created and is used internally by AutoCAD for toolbar and menu identification. Most developers do not need this level of identification and can safely ignore the TagString property.

Examples

VBA:

Sub Example_TagString()
    ' This example creates an attribute definition in model space.
    ' It then queries the tag string for the attribute, changes
    ' the tag string, and displays the new tag string.
    
    Dim attributeObj As AcadAttribute
    Dim height As Double
    Dim mode As Long
    Dim prompt As String
    Dim insertionPoint(0 To 2) As Double
    Dim tag As String
    Dim value As String
    
    ' Define the attribute definition
    height = 1#
    mode = acAttributeModeVerify
    prompt = "New Prompt"
    insertionPoint(0) = 5#: insertionPoint(1) = 5#: insertionPoint(2) = 0
    tag = "NEW_TAG"
    value = "New Value"
    
    ' Create the attribute definition object in model space
    Set attributeObj = ThisDrawing.ModelSpace.AddAttribute(height, mode, prompt, insertionPoint, tag, value)
    ZoomAll
    
    ' Find the current tag string for the attribute
    tag = attributeObj.TagString
    MsgBox "The current tag string for the attribute is " & tag, , "TagString Example"
    
    ' Change the tag string for the attribute
    attributeObj.TagString = "UPDATED_TAG"
    attributeObj.Update
    tag = attributeObj.TagString
    MsgBox "The new tag string for the attribute is " & tag, , "TagString Example"
    
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_TagString()
    ;; This example creates an attribute definition in model space.
    ;; It then queries the tag string for the attribute, changes
    ;; the tag string, and displays the new tag string.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    
    ;; Define the attribute definition
    (setq insertionPoint (vlax-3d-point 5 5 0) 
          attHeight 1
          attMode acAttributeModeVerify
          attPrompt "New Prompt"
          attTag "NEW_TAG"
          attValue "New Value")
    
    ;; Create the attribute definition object in model space
    (setq modelSpace (vla-get-ModelSpace doc))  
    (setq attributeObj (vla-AddAttribute modelSpace attHeight attMode attPrompt insertionPoint attTag attValue))
    (vla-ZoomAll acadObj)
    
    ;; Find the current tag string for the attribute
    (setq tag (vla-get-TagString attributeObj))
    (alert (strcat "The current tag string for the attribute is " tag))
    
    ;; Change the tag string for the attribute
    (vla-put-TagString attributeObj "UPDATED_TAG")
    (vla-Update attributeObj)
    (setq tag (vla-get-TagString attributeObj))
    (alert (strcat "The new tag string for the attribute is " tag))
)