# Shape.SetResults Method (Visio)

**Office 2013**

Sets the results or formulas of one or more cells.

*expression*
.SetResults(** SRCStream()**,

**,**

*UnitsNamesOrCodes()***,**

*resultArray()***)**

*Flags* *expression*
A variable that represents a **Shape** object.

### Parameters

Name | Required/Optional | Data Type | Description |
---|---|---|---|

SID_SRCStream() | Required | | An array identifying cells to be modified. |

UnitsNamesOrCodes() | Required | | Measurement units to be attributed to entries in results array. |

resultArray() | Required | | Out parameter. Results or formulas to be assigned to identified cells. |

Flags | Required | | Flags that influence the behavior of |

### Return Value

Integer

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** objects, you can use the **SetResults** method to set results of any set of cells. 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** objects, SID_SRCStream() should be a one-dimensional array of 3*n* 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.

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 UnitsNamesOrCodes()*(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 UnitsNamesOrCodes() 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 |
---|---|---|

| &H1 | Treat strings in results as formulas. |

| &H2 | Override present cell values even if they're guarded. |

| &H4 | Test for establishment of circular cell references. |

| &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.

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).

Public Sub Set Results_Example() On Error GoTo HandleError 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 the 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 'Use SetResults to: ' - Set the width of shape 1 to the height of shape 2. ' - Set the height of shape 2 to the width of shape 1. 'NOTE: avarResults() is indexed from 0 to 2. Dim varTemp As variant varTemp = avarResults(0) avarResults(0) = avarResults(1) avarResults(1) = varTemp 'Pass the same array back to SetResults that we 'just passed to GetResults, but leave the angle 'alone. By setting the sheet ID entry in the third 'slot of the aintSheetSectionRowColumn array to 'visInvalShapeID, we tell SetResults to ignore that slot. aintSheetSectionRowColumn(9) = visInvalShapeID 'Set the results of the cells. ActivePage.SetResults aintSheetSectionRowColumn, avarUnits, avarResults, 0 Exit Sub HandleError: MsgBox "Error" Exit Sub End Sub