Share via


Master.GetFormulasU Method

Visio Automation Reference

Returns the formulas of many cells.

Version Information
 Version Added:  Visio 4.5

Syntax

expression.GetFormulasU(SID_SRCStream(), formulaArray())

expression   A variable that represents a Master object.

Parameters

Name Required/Optional Data Type Description
SID_SRCStream() Required Integer A stream that identifies cells to be queried.
formulaArray() Required Variant Out paramter. An array that receives formulas of queried cells.

Return Value
Nothing

Remarks

The GetFormulasU method is like the FormulaU 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 GetFormulasU method is a specialization of the GetResults method, which can be used to obtain cell formulas or results. Setting up a call to the GetFormulasU method involves slightly less work than setting up the GetResults method.

You can use the GetFormulasU method to get formulas in universal syntax of any set of cells in any set of shapes of the page or master.

SID_SRCStream() is an array of 2-byte integers. SID_SRCStream() should be a one-dimensional array of 4n 2-byte integers for n >= 1. The GetFormulasU method interprets SID_SRCStream() as:

Visual Basic for Applications
  {sheetID, sectionIdx, rowIdx, cellIdx}n

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

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

If the GetFormulasU 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 GetFormulasU 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 GetFormulasU method returns. (Microsoft Visual Basic and Visual Basic for Applications take care of this for you.) The GetFormulasU method fails if formulaArray() is Null.

ms427120.vs_note(en-us,office.12).gif  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.

See Also