Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

DataRecordset.GetRowData Method (Visio)

Published: July 16, 2012

Gets the data in all columns in the specified row.

Note Note

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

Version Added: Visio 2007

expression .GetRowData(DataRowID)

expression An expression that returns a DataRecordset object.




Data Type





The ID of the row in the data recordset from which you want to retrieve data.

Return Value


To get the row IDs of all the rows in the data recordset, use the GetDataRowIDs method. See the example in this topic.

If you pass a row ID of zero for the DataRowID parameter, the GetRowData method returns the names of the columns in the data recordset. If you pass any other valid row ID than zero, the GetRowData method returns values for all the columns in the specified row, in the same order as the column names that the method returns when you pass zero.

This Microsoft Visual Basic for Applications (VBA) macro shows how you can use the GetDataRowIDs and GetRowData methods to return the row ID of each row and then get the data stored in each column in every row of the specified data recordset. The macro gets the count of all data recordsets associated with the current document and gets row data for the one most recently added. It iterates through all the rows in the data recordset and then, for each row, iterates through all the columns in that row. The code displays the information returned in the Immediate window.

Before running this macro, create at least one data recordset in the current document.

Note that the macro passes an empty string to the GetDataRowIDs method to bypass filtering and get all the rows in the recordset. After you run the macro, note that the first set of data shown (corresponding to the first data row) contains the headings for all the data columns in the data recordset.

Public Sub GetRowData_Example() 
    Dim vsoDataRecordset As Visio.DataRecordset 
    Dim intCount As Integer 
    Dim lngRowIDs() As Long 
    Dim lngRow As Long 
    Dim lngColumn As Long 
    Dim varRowData As Variant 
    'Get the count of all data recordsets in the current document. 
    intCount = ThisDocument.DataRecordsets.Count 
    Set vsoDataRecordset = ThisDocument.DataRecordsets(intCount) 
    'Get the row IDs of all the rows in the data recordset 
    lngRowIDs = vsoDataRecordset.GetDataRowIDs("") 
    'Iterate through all the records in the data recordset. 
    For lngRow = LBound(lngRowIDs) To UBound(lngRowIDs) + 1 
        varRowData = vsoDataRecordset.GetRowData(lngRow) 
        'Print a separator between rows 
        Debug.Print "------------------------------" 
       'Print the data stored in each column of a particular data row. 
        For lngColumn = LBound(varRowData) To UBound(varRowData) 
            Debug.Print varRowData(lngColumn) 
        Next lngColumn 
    Next lngRow 
End Sub 

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2014 Microsoft. All rights reserved.