Shape.Data2 Property

Visio Automation Reference

Gets or sets the value of the Data2 field for a Shape object. Read/write.

Version Information
 Version Added:  Visio 2.0

Syntax

expression.Data2

expression   A variable that represents a Shape object.

Return Value
String

Remarks

Use the Data2 property to supply additional information about a shape. The property can contain up to 64 KB of characters. Text controls should be used with care with a string that is greater than 3,000 characters. Setting the Data1 property is equivalent to entering information in the Data 2 box in the Special dialog box (Format menu).

Example

This Microsoft Visual Basic for Applications (VBA) macro shows how to set a shape's Data1, Data2, and Data3 properties. It prints the values of these properties in the Immediate window. You can also verify that these values have been set by opening the Special dialog box.

Visual Basic for Applications
  Public Sub Data123_Example()
Dim vsoPage As Visio.Page 
Dim vsoShape As Visio.Shape

Set vsoPage = Documents.Add("").Pages(1) 
Set vsoShape = vsoPage.DrawRectangle(3, 3, 5, 5) 

'Use the Data1, Data2, and Data3 properties to set
'the shape's Data fields. 
vsoShape.Data1 = "Data1_String" 
vsoShape.Data2 = "Data2_String" 
vsoShape.Data3 = "Data3_String" 

'Use the Data1, Data2, and Data3 properties to verify
'the shape's Data field values. 
Debug.Print vsoShape.Data1 
Debug.Print vsoShape.Data2 
Debug.Print vsoShape.Data3 

End Sub

See Also