ShapeCollection object (JavaScript API for Visio)
Applies to: Visio Online
Represents the Shape Collection.
Properties
| Property | Type | Description |
|---|---|---|
| items | Shape[] | A collection of shape objects. Read-only. |
Relationships
None
Methods
| Method | Return Type | Description |
|---|---|---|
| getCount() | int | Gets the number of Shapes in the collection. |
| getItem(key: number or string) | Shape | Gets a Shape using its key (name or Index). |
| load(param: object) | void | Fills the proxy object created in JavaScript layer with property and object values specified in the parameter. |
Method Details
getCount()
Gets the number of Shapes in the collection.
Syntax
shapeCollectionObject.getCount();
Parameters
None
Returns
int
Examples
Visio.run(function (ctx) {
var activePage = ctx.document.getActivePage();
var numShapesActivePage = activePage.shapes.getCount();
return ctx.sync().then(function () {
console.log("Shapes Count: " + numShapesActivePage.value);
});
}).catch(function(error) {
console.log("Error: " + error);
if (error instanceof OfficeExtension.Error) {
console.log("Debug info: " + JSON.stringify(error.debugInfo));
}
});
getItem(key: number or string)
Gets a Shape using its key (name or Index).
Syntax
shapeCollectionObject.getItem(key);
Parameters
| Parameter | Type | Description | |
|---|---|---|---|
| key | number or string | Key is the Name or Index of the shape to be retrieved. |
Returns
load(param: object)
Fills the proxy object created in JavaScript layer with property and object values specified in the parameter.
Syntax
object.load(param);
Parameters
| Parameter | Type | Description | |
|---|---|---|---|
| param | object | Optional. Accepts parameter and relationship names as delimited string or an array. Or, provide loadOption object. |
Returns
void
Fills the proxy object created in JavaScript layer with property and object values specified in the parameter.
Syntax
object.load(param);
Parameters
| Parameter | Type | Description | |
|---|---|---|---|
| param | object | Optional. Accepts parameter and relationship names as delimited string or an array. Or, provide loadOption object. |
Returns
void