SetResults method

Microsoft Visio Developer Reference

SetResults method

       

Sets the results or formulas of one or more cells.

Version added

4.5

Syntax

intRet object.SetResults SID_SRCStream, units, results, flags

intRet

Integer. Number of SID_SRCStream entries which processed successfully.

object

Required. An expression that returns a Page, Master, Shape, or Style whose cells are to be modified.

SID_SRCStream

Required Integer. An array identifying cells to be modified.

units

Required Variant. Measurement units to be attributed to entries in results array.

results

Required Variant. Results or formulas to be assigned to identified cells.

flags

Required Integer. Flags that influence the behavior of SetResults.

Remarks

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

For Shape or Style objects, you can use the SetResults method to set results of any set of cells.

For Page or Master objects, you can use the SetResults method to set results of any set of cells in any set of shapes of the page or master.

In both of these cases, you tell the SetResults method which cells you want to set by passing an array of integers in SID_SRCStream. SID_SRCStream is a one-dimensional array of 2-byte integers.

  • For Shape and Style objects SID_SRCStream should be a one-dimensional array of 3n 2-byte integers for n >= 1. The SetResults method interprets the stream 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 and Master objects SID_SRCStream should be a one-dimensional array of 4n 2-byte integers for n >= 1. The SetResults method interprets the stream 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 to be modified.

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

The units array controls what measurement units individual entries in results are 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 in VisUnitCodes. For a list of constants used for units of measure, see About units of measure. Note that the values specified in the units array have no effect if visSetFormulas is set in flags.

If not empty, we expect 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 entry in results is in the units designated by units(j), where j is the most recent prior entry that is not empty. Thus if you want all entries in results to be interpreted in the same units, then you need only pass a units array with one entry. If there is no prior entry that is not empty, or if no units array is supplied, then visNumber (0x20) will be used. This causes the application to default to internal units (like the ResultIU property of a Cell object).

The results argument should be a one-dimensional array of 1 <= m variants. A result can be passed as Double, Integer, String, or a reference to a String. Strings are accepted only if visSetFormulas is set in flags, in which case strings are interpreted as formulas. If results(i) is empty, then the i'th cell will be set to the value in results(j), where j is the index of the most recent prior entry which is not empty. If there is no prior entry that is not empty, the corresponding cell is not altered. If fewer results than cells are specified (m < n), then the i'th cell, i < m, will be set to the same value as was chosen to set the m'th cell to. Thus to set many cells to the same value, you need only pass one copy of the value.

The flags argument should be a bit mask of the following values.

Constant

Value

Description

visSetFormulas

&H1

Treat strings in results as formulas.

visSetBlastGuards

&H2

Override present cell values even if they're guarded.

visSetTestCircular

&H4

Test for establishment of circular cell references.

visSetUniversalSyntax

&H8

Formulas are in universal syntax

The value returned by the SetResults method is the number of entries in SID_SRCStream that were successfully processed. If i < n entries process correctly, but an error occurs on the i + 1st entry, then the SetResults method raises an exception and returns i. Otherwise, n is returned.