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

DataColumns.SetColumnProperties Method (Visio)

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

Sets one or more data-column properties for one or more data columns.

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


expression . SetColumnProperties( ColumnNames() , Properties() , Values() )

expression An expression that returns a DataColumns object.


NameRequired/OptionalData TypeDescription
ColumnNames()RequiredStringAn array of strings that represent data column names.
Properties()RequiredLongAn array of data-column properties, as VisDataColumnProperties . See Remarks for possible values.
Values()RequiredVariantAn array of values to be assigned to the properties. See Remarks for possible values.

Return Value



The SetColumnProperties method is a more efficient way to set properties for multiple data columns simultaneously than is setting properties one column at a time. Depending on the items you place in each of the three parameter arrays, you can change multiple properties of the same data column or one or more properties of different data columns. For each change you want to make, pass related column-name/property/value triplets at corresponding positions of all three arrays. Note that the size of all three arrays that you pass to the method must be the same, or the method will return an error.

For the ColumnNames() parameter, pass an array of the names of the data columns whose properties you want to change. If you want to change multiple properties of the same column, you can either place the same name in multiple array positions, or you can place the column name in one array position and place empty strings in the succeeding positions that correspond to the array positions of the properties you want to change.

Possible values for items in the Properties() parameter array are declared in VisDataColumnProperties , and are shown in the following table.

** visDataColumnPropertyCalendar**3Calendar of the data-column property.
visDataColumnPropertyCurrency5Currency of the data-column property.
visDataColumnPropertyDisplayName6Display name of the data-column property in the UI.
visDataColumnPropertyHyperlink8Whether the data-column value becomes a hyperlink in the Visio UI when it is linked to a shape.
visDataColumnPropertyLangID2Language ID of the data-column property.
visDataColumnPropertyType1Data type of the data-column property.
visDataColumnPropertyUnits4Units of the data-column property.
visDataColumnPropertyVisible7Whether the data-column property is visible in the UI.

Possible values for items in the Values() parameter array depend on the corresponding Property() array parameter values. The table in the DataColumn.SetProperty topic shows valid data-column property values for each data-column property, depending on the data-column data type.


The following Microsoft Visual Basic for Applications (VBA) macro shows how to set the value of a single property for two different columns in the most recently added recordset in the DataRecordsets collection of the active document. The macro assumes that the most recently added recordset is one based on data in the ORGDATA.xls spreadsheet that is shipped with Visio. Sample code for adding that data recordset is shown in the DataRecordsets.Add method topic. However, you can use this code with any data recordset that has at least two columns.

The macro changes the display name of the first column to "Dept." and sets the Hyperlink property of the second column to True . Thereafter (if you used ORGDATA as your data source), the e-mail address of shapes linked to data in the data recordset will act as a hyperlink.

Note that changing the display name of a data column changes only its DisplayName property, and does not change the column's programmatic name, which is specified by its Name property.

Public Sub SetColumnProperties_Example() 

    Dim vsoDataRecordset As Visio.DataRecordset 
    Dim intCount As Integer 

    intCount = Visio.ActiveDocument.DataRecordsets.Count 
    Set vsoDataRecordset = Visio.ActiveDocument.DataRecordsets(intCount) 

    Dim astrColumnNames(1) As String 
    Dim alngProperties(1) As Long 
    Dim avarValues(1) As Variant 

    astrColumnNames(0) = vsoDataRecordset.DataColumns(1).DisplayName 
    astrColumnNames(1) = vsoDataRecordset.DataColumns(2).DisplayName 

    alngProperties(0) = visDataColumnPropertyDisplayName 
    alngProperties(1) = visDataColumnPropertyHyperlink 

    avarValues(0) = "Dept." 
    avarValues(1) = True 

    vsoDataRecordset.DataColumns.SetColumnProperties astrColumnNames, alngProperties, avarValues 

End Sub
© 2017 Microsoft