Table of contents
TOC
折叠目录
展开目录

Page.DropManyU 方法 (Visio)Page.DropManyU Method (Visio)

office 365 dev account|上次更新日期: 2018/3/13
|
2 参与人员

在页面、 主控形状或组中创建一个或多个新的Shape对象。它返回一个数组,则生成的Shape对象的 id。Creates one or more new Shape objects on a page, in a master, or in a group. It returns an array of the IDs of the Shape objects it produces.

语法Syntax

表达式DropManyU( ObjectsToInstance()xyArray()IDArray() )expression . DropManyU( ObjectsToInstance() , xyArray() , IDArray() )

表达式_一个表示一个Page对象的变量。_expression A variable that represents a Page object.

参数Parameters

名称Name必需/可选Required/Optional数据类型Data Type说明Description
ObjectsToInstance()ObjectsToInstance()必需RequiredVariantVariant标识根据其通用名称从中创建形状的主控形状或其他对象。Identifies masters or other objects from which to make shapes by their universal names.
xyArray()xyArray()必需RequiredDoubleDouble一个交替出现_x_和_y_指定新建形状的位置的值的数组。An array of alternating x and y values that specify the positions for the new shapes.
IDArray()IDArray()必需RequiredIntegerIntegerout 参数。一个返回所创建形状的 ID 的数组。Out parameter. An array that returns the IDs of the created shapes.

返回值Return Value

IntegerInteger

注解Remarks

使用DropManyU方法就像使用了页面主控形状,或者形状对象的Drop方法,除了可以使用DropManyU方法而不是每一次,创建多个新的Shape对象方法调用。DropManyU方法在页面上,在母版上,或应用于组合形状中创建新的Shape对象 (此形状在下面的讨论中称为"目标对象")。Using the DropManyU method is like using the Page , Master , or Shape object's Drop method, except you can use the DropManyU method to create many new Shape objects at once, rather than one per method call. The DropManyU 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).

您可以确定哪些主机放置一个主控形状或主控形状的索引或主控形状的名称,通过DropManyU方法。当传递一个对象时,dropmanyu 并不仅仅是从被放到其上的文档的文档模具中放置主控。对象可以是对象的另一个文档或其他类型中的主控形状。You can identify which master to drop by passing the DropManyU method a Master object or the master's index or the master's name. When you pass an object, DropManyU 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.

将整数 (主控形状索引) 或字符串 (主控形状名称) 传递给DropManyU比传递对象速度快但整数或字符串可以标识只能被放到其上的文档的文档模具中的主控形状。因此程序不得不以某种方式进入母版问题文档模具的初衷,还没有提供。Passing integers (master indices) or strings (master names) to DropManyU 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()_应该是一个一维数组的_n> = 1 变种。各项标识想要新的Shape对象的对象。项通常是指 Microsoft Visio 应用程序主机对象。它还可能从其他应用程序请参阅 Visio 应用程序形状对象、选择对象或甚至一个对象。应用程序不在意下限和上限数组界限的_ObjectsToInstance()条目是什么。调用这些_vlb_和_vub ,分别。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 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.

  • 如果_ObjectsToInstance(i)是整数_j ,进行基于 1 的索引是_j_的目标对象的文档的文档模具中的主控形状对象的一个实例。不触发新形状的事件部分中的 EventDrop 单元格。如果想要触发的 EventDrop 单元格,请使用拖放方法。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 trigger.

  • 如果_ObjectsToInstance(i)是字符串_s (或对_字符串_的引用),则进行_s_的文档模具中目标对象的文档名称与对象的一个实例;s_可以等于两对象的UniqueIDNameU属性。不触发新形状的事件部分中的 EventDrop 单元格。如果您想要触发的 EventDrop 单元格,请使用Drop方法。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 NameU 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.

  • 对于_vlb_ < i <= vub ,如果_ObjectsToInstance(i)为空 (; 在未初始化的 Microsoft Visual Basic) 项_我_会导致_ObjectsToInstance(j)_来实例化,其中_j_是最大值 < _iObjectsToInstance(j)_不为空。如果您想要_n_了相同内容的情况下,需要提供只有_ObjectsToInstance(vlb)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.

XyArray()_参数应为 2 _m_双精度型值与_xylb_的下界和上界_xyub ,一个一维数组, m >= n 。数组中的值告诉DropManyU方法来定位它生成的Shape对象的位置。ObjectsToInstance()( vlb + ( i-1)) 上丢弃 ( xy [( i -1) 2 + xylb ], xy [(i-1) 2 + xylb + 1]) 1 < = i <= nThe xyArray() parameter should be a one-dimensional array of 2 m doubles with lower bound xylb and upper bound xyub , where m >= n . The values in the array tell the DropManyU 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 .

请注意_m_ > n_允许的。对于_n < i <= m我_实例的第一点是不同于_n' th 事情能实例化。从而使_m_ > = 1 了相同内容的情况下,您可以传递_m_项_xyArray()数组和数组_ObjectsToInstance()_一个条目。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.

如果被实例化的实体是一个母版,在给定的_xy_定位新的Shape对象的旋转中心点。否则,在给定的_xy_定位形状对象的中心。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 .

DropManyU方法返回的整数值是_xy_ DropManyU方法成功处理的_xyArray_中的条目数。如果所有项都已成功都处理,则返回_m_ 。如果成功处理部分项后发生错误,则生成的Shape对象不会删除,这将引发异常,但仍返回一个正整数。The Integer value returned by the DropManyU method is the number of xy entries in xyArray that the DropManyU 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 integer.

假定_m_ xy_的所有条目都已正确都处理,是通常等于_mDropManyU方法生成的新形状对象的数目。(例如,如果选择对象获取实例化) 的极少数情况下,可能会产生比_m_形状对象的详细信息。调用方可以通过比较目标对象之前和之后执行DropManyU方法形状数来确定生成的Shape对象的数目。调用方可以断言,这些目标对象的形状集合中的最大索引记录新的Shape对象。Presuming all mxy entries are processed correctly, the number of new Shape objects produced by the DropManyU 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 DropManyU method is executed. The caller can assert the new Shape objects are those with the highest indices in the target object's Shapes collection.

如果DropManyU方法返回零 (0) 时, IDArray()_将返回 null (没有)。否则,它返回索引从 0 到_m -1 m_整数的一维数组。_IDArray()_是由DropManyU方法分配的输出参数,所有权传递给DropManyU调用的程序。调用方应最终在返回的数组中执行SafeArrayDestroy过程。(Microsoft Visual Basic 和 Microsoft Visual Basic for Applications 负责这您。)If the DropManyU 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 DropManyU method and ownership is passed to the program that called the DropManyU 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.)

如果_IDArray()返回非 null (不执行任何操作), _IDArray( i -1),1 < = i <= intReturned ,返回Shape对象,该对象由_我_的 ID ' th xyArray()_项,提供_i ' th xyArray()_条目生成一个Shape对象。如果_我' th xyArray()_条目生成多个图形对象,在条目,则返回-1。所有条目_iintReturned <= i < m ,返回-1。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.

请注意 从 Microsoft Visio 2000 开始,可以使用本地和通用名称来指代 Visio 形状、 主控形状、 文档、 页面、 行、 加载项、 单元格、 超链接、 样式、 字体、 主控形状快捷方式、 用户界面对象和图层。当用户为某个形状命名时,例如,用户指定的本地名称。从 Microsoft Office Visio 2003 开始,ShapeSheet 电子表格中单元格的公式和值显示只有通用名称。(在先前版本中,通用名称都不可见的用户界面中。)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.)

作为开发人员,您可以在程序中使用通用名称时,您不希望每次本地化解决方案时都更改名称。DropMany方法用于使用本地名称来标识形状时删除多个形状。DropManyU方法用于使用通用名称来标识形状时删除多个形状。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.

示例Example

下面的示例演示如何使用DropManyU方法。它到 Page1 的宏的文档对象的宏的文档对象的文档模具中删除每个母版的一个实例。运行此宏之前,请确保有至少一个主文档模具中。The following example shows how to use the DropManyU 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.


Public Sub DropManyU_Example() 

 On Error GoTo HandleError 

 Dim vsoMasters As Visio.Masters 
 Dim intMasterCount As Integer 
 Set vsoMasters = ThisDocument.Masters 
 intMasterCount = vsoMasters.Count 

 ReDim varObjectsToInstance(1 To intMasterCount) As Variant 
 ReDim adblXYArray(1 To (intMasterCount * 2)) As Double 
 Dim intCounter As Integer 
 For intCounter = 1 To intMasterCount 

 'Pass universal name of object to drop to DropManyU. 
 varObjectsToInstance(intCounter) = vsoMasters.ItemU(intCounter).NameU 

 'Set x components of where to drop to 2,4,6,2,4,6,2,4,6,... 
 adblXYArray (intCounter * 2 - 1) = (((intCounter - 1) Mod 3) + 1) * 2 

 'Set y components to 2,2,2,4,4,4,6,6,6,... 
 adblXYArray (intCounter * 2) = Int((intCounter + 2) / 3) * 2 

 Next intCounter 

 Dim aintIDArray() As Integer 
 Dim intProcessed As Integer 

 intProcessed = ThisDocument.Pages(1).DropManyU(varObjectsToInstance, _ 
 adblXYArray, aintIDArray) 
 Debug.Print intProcessed 

 For intCounter = LBound(aintIDArray) To UBound(aintIDArray) 
 Debug.Print intCounter; aintIDArray(intCounter) 
 Next intCounter 

 Exit Sub 

 HandleError: 
 MsgBox "Error" 

 Exit Sub 

End Sub
© 2018 Microsoft