Table of contents
TOC
Collapse the table of content
Expand the table of content

GraphicItem.GetExpression Method (Visio)

office 365 dev account|Last Updated: 6/12/2017
|
1 Contributor

Gets the label of the shape data item (custom property) that the GraphicItem represents, or the value of the expression string that is part of a GraphicItem object?s rule, against which shape data is evaluated.

Note This Visio object or member is available only to licensed users of Visio Professional 2013.

Syntax

expression . GetExpression( Field , Expression )

expression An expression that returns a GraphicItem object.

Parameters

NameRequired/OptionalData TypeDescription
FieldRequiredVisGraphicFieldOut parameter. A constant value from the VisGraphicField enumeration specifying whether Expression is a shape-data-item label or the formula in the ShapeSheet spreadsheet of the primary data field (column) assigned to the GraphicItem . See Remarks for possible values.
ExpressionRequiredStringOut parameter. The ShapeSheet expression associated with the Field parameter.

Return Value

Nothing

Remarks

The Field value returned as an out parameter is one of the following values from the VisGraphicField enumeration, which is declared in the Microsoft Visio type library.

ConstantValueDescription
visGraphicPropertyLabel1The label of a shape data item.
visGraphicExpression2The ShapeSheet formula of a shape data item.

Example

The following Microsoft Visual Basic for Applications (VBA) macro shows how to use the GetExpression method to get the value of the expression string for a data graphic item. It gets the most recently applied expression for the first graphic item in the GraphicItems collection of the Master object of type visTypeDataGraphic (commonly called a data graphic) named "Data Graphic," and prints the field and the expression in the Immediate window.

Note You can determine the name of an existing data graphic master by moving your mouse over the master in the Data Graphics task pane in the Visio user interface.

The macro assumes that a data graphic named "Data Graphic" exists in the current document. For more information about adding a data graphic master to the Masters collection of the current document, see Masters.AddEx .

Public Sub GetExpression() 

    Dim vsoGraphicItem As Visio.GraphicItem 
    Set vsoGraphicItem = ActiveDocument.Masters("Data Graphic").GraphicItems(1) 
    Dim strExpression As String 
    Dim fieldName As VisGraphicField 

    vsoGraphicItem.GetExpression fieldName, strExpression 
    Debug.Print strExpression 
    Debug.Print fieldName 

End Sub
© 2018 Microsoft