Share via


Shape.GetResults Method

Visio Automation Reference

Gets the results or formulas of many cells.

Version Information
 Version Added:  Visio 4.5

Syntax

expression.GetResults(SRCStream(), Flags, UnitsNamesOrCodes(), resultArray())

expression   A variable that represents a Shape object.

Parameters

Name Required/Optional Data Type Description
SID_SRCStream() Required Integer An array that identifies cells to be queried.
Flags Required Integer Flags that influence the type of entries returned in results.
UnitsNamesOrCodes() Required Variant An array of measurement units that results are to be returned in.
resultArray() Required Variant Out parameter. An array that receives results or formulas of queried cells.

Return Value
Nothing

Remarks

The GetResults method is like the Result property for the Cell object, except that it can be used to get the results (values) of many cells at once, rather than one cell at a time.

For Shape objects, you can use the GetResults method to get results of any set of cells.

SID_SRCStream() is an array of 2-byte integers. For Shape objects, SID_SRCStream() should be a one-dimensional array of 3n 2-byte integers for n >= 1. The GetResults method interprets SID_SRCStream() as:

Visual Basic for Applications
  {sectionIdx, rowIdx, cellIdx }n

where sectionIdx is the section index of the desired cell, rowIdx is its row index and cellIdx is its cell index.

The Flags argument indicates what data type the returned results should be expressed in. Its value should be one of the following.

Constant Value Description

visGetFloats

0

Results returned as doubles (VT_R8).

visGetTruncatedInts

1

Results returned as truncated long integers (VT_I4).

visGetRoundedInts

2

Results returned as rounded long integers (VT_I4).

visGetStrings

3

Results returned as strings (VT_BSTR).

visGetFormulas

4

Formulas returned as strings (VT_BSTR).

visGetFormulasU

5

Formulas returned in universal syntax (VT_BSTR).

The UnitsNamesOrCodes() parameter is an array that controls what measurement units individual results are returned in. Each entry in the array can be a string such as "inches", "inch", "in.", or "i". Strings may be used for all supported Visio units such as centimeters, meters, miles, and so on. You can also indicate desired units with integer constants (visCentimeters, visInches, etc.) declared by the Visio type library. Note that the values specified in the UnitsNamesOrCodes() array have no effect if Flags is visGetFormulas.

If UnitsNamesOrCodes is not null, the application expects it to be a one-dimensional array of 1 <= uVariants. Each entry can be a string or integer code, or empty (nothing). If the i'th entry is empty, the i'th returned result is returned in the units designated by UnitsNamesOrCodes(j), where j is the index of the most recent prior non-empty entry. Thus if you want all returned values to be in the same units, you need only pass a UnitsNamesOrCodes() array with one entry. If there is no prior non-empty entry, or if no UnitsNameOrCodes() array is supplied, visNumber (0x20) is used. This causes internal units (like the ResultIU property of a Cell object) to be returned.

If the GetResults method succeeds, results returns a one-dimensional array of n variants indexed from zero (0) to n - 1. The type of the returned variants is a function of Flags. The resultArray() parameter is an out parameter that is allocated by the GetResults method, which passes ownership back to the caller. The caller should eventually perform SafeArrayDestroy on the returned array. Note that SafeArrayDestroy has the side effect of clearing the variants referenced by the array's entries, hence deallocating any strings the GetResults method returns. (Microsoft Visual Basic and Microsoft Visual Basic for Applications take care of this for you.)

Example

The following example shows how to use the GetResults method. This example assumes there is an active page that has at least 3 shapes on it. It uses the GetResults method to get the width of shape 1, the height of shape 2, and the angle of shape 3.

This example uses the GetResults method of the Page object to get 3 cell formulas. The input array has 4 slots for each cell, as it also would for Master objects. For Shape or Style objects, only 3 slots would be needed for each cell (section, row, and cell).

Visual Basic for Applications
  
Public Sub GetResults_Example()
 
    On Error GoTo HandleError 
Dim intCounter As Integer    
Dim aintSheetSectionRowColumn(1 To (3 * 4)) As Integer 

aintSheetSectionRowColumn(1) = ActivePage.Shapes(1).ID 
aintSheetSectionRowColumn(2) = visSectionObject 
aintSheetSectionRowColumn(3) = visRowXFormOut 
aintSheetSectionRowColumn(4) = visXFormWidth 

aintSheetSectionRowColumn(5) = ActivePage.Shapes(2).ID 
aintSheetSectionRowColumn(6) = visSectionObject 
aintSheetSectionRowColumn(7) = visRowXFormOut 
aintSheetSectionRowColumn(8) = visXFormHeight 

aintSheetSectionRowColumn(9) = ActivePage.Shapes(3).ID 
aintSheetSectionRowColumn(10) = visSectionObject 
aintSheetSectionRowColumn(11) = visRowXFormOut 
aintSheetSectionRowColumn(12) = visXFormAngle 

'Get first two values in inches. The second element in 
'the units array is left uninitialized (empty) because we 
'want the second result in the same units as the first 
'result. The third result is initialized in degrees. Note that 
'units can be expressed as a string or an integer constant. 
Dim avarUnits(1 To 3) As Variant 
avarUnits(1) = "in." 
avarUnits(3) = visDegrees 

'Return results of cells as an array of floating point numbers. 
Dim avarResults() As Variant 
ActivePage.GetResults aintSheetSectionRowColumn, visGetFloats, _ 
    avarUnits, avarResults

For intCounter = 0 To 3
    Debug.Print avarResults(intCounter)
Next

Exit Sub

HandleError: MsgBox "Error" Exit Sub

End Sub

See Also