|Visio Automation Reference|
Creates one or more new Shape objects on a page. It returns an array of the IDs of the Shape objects it produces.
Version Added: Visio 4.5
expression.DropMany(ObjectsToInstance(), xyArray(), IDArray())
expression A variable that represents a Page object.
|ObjectsToInstance()||Required||Variant||Identifies masters or other objects from which to make shapes.|
|xyArray()||Required||Double||An array of alternating x and y values specifying the positions for the new shapes.|
|IDArray()||Required||Integer||Out parameter. An array that returns the IDs of the created shapes.|
Using the DropMany method is like using the Page, Master, or Shape object's Drop method, except you can use the DropMany method to create many new Shape objects at once, rather than one per method call. The DropMany method creates new Shape objects on the page, in the master, or in the group shape to which it is applied (this shape is called the "target object" in the following discussion).
You can identify which master to drop by passing the DropMany method a Master object or the master's index or the master's name. When you pass an object, DropMany isn't constrained to just dropping a master from the document stencil of the document onto which it is being dropped. The object can be a master from another document or another type of object.
Passing integers (master indices) or strings (master names) to DropMany is faster than passing objects, but integers or strings can identify only masters in the document stencil of the document onto which it is being dropped. Hence your program has to somehow get the masters in question into the document stencil in the first place, provided they weren't there already.
ObjectsToInstance() should be a one-dimensional array of n >= 1 variants. Its entries identify objects from which you want to make new Shape objects. An entry often refers to a Microsoft Office Visio application Master object. It might also refer to a Visio application Shape object, Selection object, or even an object from another application. The application doesn't care what the lower and upper array bounds of the ObjectsToInstance() entries are. Call these vlb and vub, respectively.
- If ObjectsToInstance(i) is a reference to an OLE object that provides an IDataObject interface (in Microsoft Visual Basic for Applications, a reference to a selection, shape, master, guide, or OLE object), the object it is referencing is instanced. This is essentially equivalent to calling Drop*(ObjectsToInstance(i),x,y)*.
- If ObjectsToInstance(i) is the integer j, an instance of the Master object in the document stencil of the target object's document whose 1-based index is j is made. The EventDrop cell in the Events section of the new shape is not triggered. Use the Drop method instead if you want the EventDrop cell to be triggered.
- If ObjectsToInstance(i) is the string s (or a reference to the string s), an instance of the Master object with name s in the document stencil of the target object's document is made; s can equal either the Master object's UniqueID or Name property. The EventDrop cell in the Events section of the new shape is not triggered. Use the Drop method instead if you want the EventDrop cell to be triggered.
- For vlb < i <= vub, if ObjectsToInstance(i) is empty (Nothing or uninitialized in Microsoft Visual Basic), entry i will cause ObjectsToInstance(j) to be instanced again, where j is the largest value < i such that ObjectsToInstance(j) isn't empty. If you want to make n instances of the same thing, only ObjectsToInstance(vlb) needs to be provided.
The xyArray() argument should be a one-dimensional array of 2m doubles with lower bound xylb and upper bound xyub, where m >= n. The values in the array tell the DropMany method where to position the Shape objects it produces. ObjectsToInstance(vlb + ( i - 1)) is dropped at (xy[(i - 1)2 + xylb],xy[(i - 1)2 + xylb + 1]) for 1 <= i <=n.
Note that m > n is allowed. For n < i <= m, the i'th thing instanced is the same thing as the n'th thing instanced. Thus to make m >= 1 instances of the same thing, you can pass an ObjectsToInstance() array with one entry and an m entry xyArray() array.
If the entity being instanced is a master, the pin of the new Shape object is positioned at the given xy. Otherwise, the center of the Shape objects is positioned at the given xy.
The value returned by the DropMany method is the number of xy entries in xyArray() that the DropMany method successfully processed. If all entries were processed successfully, m is returned. If some entries are successfully processed prior to an error occurring, the produced Shape objects are not deleted and this raises an exception but still returns a positive value.
Presuming all mxy entries are processed correctly, the number of new Shape objects produced by the DropMany method is usually equal to m. In rare cases (for example, if a Selection object gets instanced), more than mShape objects may be produced. The caller can determine the number of produced Shape objects by comparing the number of shapes in the target object before and after the DropMany method is executed. The caller can assert the new Shape objects are those with the highest indices in the target object's Shapes collection.
If the DropMany method returns zero (0), IDArray returns null (Nothing). Otherwise, it returns a one-dimensional array of m integers indexed from 0 to m - 1. IDArray() is an out parameter that is allocated by the DropMany method and ownership is passed to the program that called the DropMany method. The caller should eventually perform the SafeArrayDestroy procedure on the returned array. (Microsoft Visual Basic and Microsoft Visual Basic for Applications take care of this for you.)
If IDArray returns non-null (not Nothing), IDArray(i - 1), 1 <= i <= intReturned, returns the ID of the Shape object produced by the i'th xyArray() entry, provided the i'th xyArray() entry produced exactly one Shape object. If the i'th xyArray() entry produced multiple Shape objects, -1 is returned in the entry. All entries i, intReturned <= i < m, return -1.
|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 DropMany method to drop more than one shape when you are using local names to identify the shapes. Use the DropManyU method to drop more than one shape when you are using universal names to identify the shapes.
The following example shows how to use the DropMany method. It drops one instance of every master in the document stencil of the macro's Document object onto Page1 of the macro's Document object. Before running this macro, make sure there is at least one master in the document stencil.
|Visual Basic for Applications|