GetResults method

Microsoft Visio Developer Reference

GetResults method

       

Gets the results or formulas of many cells.

Version added

4.5

Syntax

object.GetResults SID_SRCStream, flags, units, results

object

Required. An expression that returns a Page, Master, Shape, or Style object.

SID_SRCStream

Required Integer. Array identifying cells to be queried.

flags

Required Integer. Flags that influence the type of entries returned in results.

units

Required Variant. Array of measurement units that results are to be returned in.

results

Required Variant. Array that receives results or formulas of queried cells.

Remarks

The GetResults method is like the Result method 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 or Style objects, you can use the GetResults method to get results of any set of cells.

For a Page or Master object, you can use the GetResults method to get results of any set of cells in any set of shapes of the page or master.

SID_SRCStream is an array of 2-byte integers:

  • For Shape or Style objects, SID_SRCStream should be a one-dimensional array of 3n 2-byte integers for n >= 1. The GetResults method interprets SID_SRCStream as:
{ 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.

  • For Page or Master objects, SID_SRCStream should be a one-dimensional array of 4n 2-byte integers for n >= 1. The GetResults method interprets SID_SRCStream as:
{ sheetID, sectionIdx, rowIdx, cellIdx }n

where sheetID is the ID property of the Shape object on the page or master whose cell result is desired.

Note If the sheetID in an entry is visInvalShapeID (-1) or if the bottom byte of sectionIdx is visSectionInval (255), then the entry will be ignored and an empty variant will be returned in the corresponding results array entry. The motivation for this is that the same SID_SRCStream array can be used on several calls to GetResults, SetResults, and similar methods with the caller only needing to make minor changes to the stream between calls.

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 units argument 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 units array have no effect if flags is visGetFormulas.

If not null, the application expects units to be a one-dimensional array of 1 <= u Variants. Each entry can be a string or integer code, or empty (nothing). If the i'th entry is empty, then the i'th returned result is returned in the units designated by units(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 units array with one entry. If there is no prior non-empty entry, or if no units array is supplied, then 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. Results is an out argument 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 Visual Basic for Applications take care of this for you.)