Shape.GetFormulas Method
Visio Automation Reference |
Returns the formulas of many cells.
Version Information
Version Added: Visio 4.5
Syntax
expression.GetFormulas(SRCStream(), formulaArray())
expression A variable that represents a Shape object.
Parameters
Name | Required/Optional | Data Type | Description |
---|---|---|---|
SID_SRCStream() | Required | Integer | A stream identifying cells to be queried. |
formulaArray() | Required | Variant | Out parameter. An array that receives formulas of queried cells. |
Return Value
Nothing
Remarks
The GetFormulas method is like the Formula property of a Cell object, except you can use it to obtain the formulas of many cells at once rather than one cell at a time. The GetFormulas method is a specialization of the GetResults method, which can be used to obtain cell formulas or results. Setting up a call to the GetFormulas method involves slightly less work than setting up the GetResults method.
For Shape objects, you can use the GetFormulas method to get formulas 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 some n >= 1. GetFormulas interprets the stream as:
Visual Basic for Applications |
---|
|
where sectionIdx is the section index of the desired cell, rowIdx is its row index and cellIdx is its cell index.
If the GetFormulas method succeeds, formulaArray() returns a one-dimensional array of n variants indexed from 0 to n - 1. Each variant returns a formula as a string. formulaArray() is an out parameter that is allocated by the GetFormulas method, which passes ownership back to the caller. The caller should eventually perform the SafeArrayDestroy procedure on the returned array. Note that the SafeArrayDestroy procedure has the side effect of clearing the variants referenced by the array's entries, hence deallocating any strings the GetFormulas method returns. (Microsoft Visual Basic and Visual Basic for Applications take care of this for you.) The GetFormulas method fails if formulaArray() is Null.
Note |
---|
Beginning with Microsoft Visio 2000, you can use both local and universal names to refer to Visio shapes, masters, documents, pages, rows, add-ons, cells, hyperlinks, styles, fonts, master shortcuts, UI objects, and layers. When a user names a shape, for example, the user is specifying a local name. Beginning with Microsoft Office Visio 2003, the ShapeSheet spreadsheet displays only universal names in cell formulas and values. (In prior versions, universal names were not visible in the user interface.) |
As a developer, you can use universal names in a program when you don't want to change a name each time a solution is localized. Use the GetFormulas method to get more than one formula when you are using local syntax. Use the GetFormulasU method to get more than one formula when you are using universal syntax.
Example
The following macro shows how to use the GetFormulas method. It assumes that there is an active Microsoft Office Visio page that has at least three shapes on it. It uses GetFormulas to get the width of shape 1, the height of shape 2, and the angle of shape 3.
This example uses the GetFormulas method of the Page object to get three cell formulas. The input array has four slots for each cell, as it also would for Master objects. For Shape or Style objects, only three slots would be needed for each cell (section, row, and cell).
Visual Basic for Applications |
---|
|
See Also