将第一个形状中的单元格中的一个形状与第二个形状中的 x, y 位置粘附到另一个形状。
语法
表达式。GlueToPos (SheetObject、 xPercent、 yPercent)
表达 一个代表 Cell 对象的变量。
参数
名称 | 必需/可选 | 数据类型 | 说明 |
---|---|---|---|
SheetObject | 必需 | [IVSHAPE] | 返回要粘附到的 Shape 对象的表达式。 |
xPercent | 必需 | Double | 要粘附到的位置的 x 坐标。 |
yPercent | 必需 | Double | 要粘附到的位置的 y 坐标。 |
返回值
Nothing
注解
GlueToPos 方法将在由 xPercent 和 yPercent(分别表示指定形状的宽度和高度的小数部分)而不是由坐标确定的位置创建新的连接点。 例如,下面的示例在 SheetObject 的中心创建了一个连接点并将形状中由 cellObject 表示的部分粘附到该点:
cellObject。 GlueToPosSheetObject, 0.5, 0.5
粘附控件节行或 BeginX 或 EndX 单元格的 X 单元格可分别自动粘附控件节行或 BeginY 或 EndY 单元格的 Y 单元格。 (反之则为 true。)
示例
下面的示例说明如何使用 GlueToPos 方法将形状粘附在一起。
Public Sub GlueToPos_Example()
Dim vso1DShape As Visio.Shape
Dim vso2DShape1 As Visio.Shape
Dim vso2DShape2 As Visio.Shape
Dim vsoCellGlueFromBegin As Visio.Cell
Dim vsoCellGlueFromEnd As Visio.Cell
'Draw a line.
Set vso1DShape = ActivePage.DrawLine(3, 5, 5, 3)
'Draw the lower rectangle.
Set vso2DShape1 = ActivePage.DrawRectangle(1, 1, 4, 2)
'Draw the upper rectangle.
Set vso2DShape2 = ActivePage.DrawRectangle(5, 5, 8, 6)
'Get the Cell objects needed to make the connections.
Set vsoCellGlueFromBegin = vso1DShape.Cells("BeginX")
Set vsoCellGlueFromEnd = vso1DShape.Cells("EndX")
'Use the GlueToPos method to glue the begin point of the 1D shape
'to the top center of the lower 2D shape.
vsoCellGlueFromBegin.GlueToPos vso2DShape1, 0.5, 1
'Use the GlueToPos method to glue the endpoint of the 1D shape
'to the bottom center of the upper 2D shape.
vsoCellGlueFromEnd.GlueToPos vso2DShape2, 0.5, 0
End Sub
支持和反馈
有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。