Page.SetResults Method
Visio Automation Reference |
Sets the results or formulas of one or more cells.
Version Information
Version Added: Visio 4.5
Syntax
expression.SetResults(SID_SRCStream(), UnitsNamesOrCodes(), resultArray(), Flags)
expression A variable that represents a Page object.
Parameters
Name | Required/Optional | Data Type | Description |
---|---|---|---|
SID_SRCStream() | Required | Integer | An array identifying cells to be modified. |
UnitsNamesOrCodes() | Required | Variant | Measurement units to be attributed to entries in results array. |
resultArray() | Required | Variant | Results or formulas to be assigned to identified cells. |
Flags | Required | Integer | Flags that influence the behavior of SetResults. |
Return Value
Integer
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 Page 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.
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 Page objects, SID_SRCStream() should be a one-dimensional array of 4n 2-byte integers for n >= 1. The SetResults method interprets the stream as:
Visual Basic for Applications |
---|
|
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), 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 UnitsNamesOrCodes() 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 Microsoft Office Visio units such as centimeters, meters, miles, and so on. You can also indicate desired units with integer constants (visCentimeters, visInches, and so on) 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 UnitsNamesOrCodes() array have no effect if visSetFormulas is set in Flags.
If UnitsNamesOrCodes() is not empty, we expect it 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, the i'th entry in resultArray() 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 resultArray() to be interpreted in the same units, you need only pass a UnitsNamesOrCodes() array that has one entry. If there is no prior entry that is not empty, or if no units array is supplied, visNumber (0x20) will be used. This causes the application to default to internal units (as does the ResultIU property of a Cell object).
The resultArray() parameter 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 resultArray(i) is empty, the i'th cell will be set to the value in resultArray(j), where j is the index of the most recent prior entry that 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 (if m < n), the i'th cell, i < m, will be set to the same value as the m'th cell. Thus, to set many cells to the same value, you need only pass one copy of the value.
The Flags parameter should be a bitmask 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 are processed correctly, but an error occurs on the i + 1st entry, the SetResults method raises an exception and returns i. Otherwise, n is returned.
Example
The following example shows how to use the SetResults 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. It then uses SetResults to set the width of shape 1 to the height of shape 2 and the height of shape 2 to the width of shape 1.The angle of shape 3 is left unaltered.
This example uses the GetResults method of the Page object to get 3 cell formulas and the SetResults method of the same object to set the 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 are needed for each cell (section, row, and cell).
Visual Basic for Applications |
---|
|
See Also