如何自动排列循环自动绘制的形状?
How to automatically arrange shapes automatically drawn by loop?
我有一个在 visio 绘图上自动生成矩形的循环,但我需要有脚本来自动排列它们,因为我知道我在标题框下手动重新排列矩形时录制了一个宏。但是我的矩形计数不断变化,因为我的 if 语句的结果不断变化,因为我的数据不断变化。我需要我的循环开始在标题框下以六个或七个矩形的列绘制它们。
For I = 1 To WS_Count
Set vsoShape =
Application.ActiveWindow.Page.Drop(Application.DefaultRectangleDataObject,
aoffset, boffset)
vsoShape.Text = ActiveWorkbook.Worksheets(I).Name
aoffset = aoffset
boffset = boffset + 0.75
Dev_Count = Dev_Count + 1
ActiveDocument.DiagramServicesEnabled = DiagramServices
Next I
我需要能够设置一个起始位置,以开始将矩形放在标题矩形下方,每六到七个矩形创建一个新列。谢谢
每次 I
被您想要的水平形状数整除时增加 aOffset...
您可以使用 Mod Operator If (iterator Mod runEveryXIterations = 0) Then ...
下面的例子应该能理清思路,代码不是你需要的,但你应该能理解思路:
Option Explicit
Public Sub printXY()
xyDistribute 10, 3, 0, 0, 0.75, 1.5
End Sub
Private Function xyDistribute(ByRef iterations As Long, _
ByRef newColAfter As Long, _
ByRef xPosInitial As Double, _
ByRef yPosInitial As Double, _
ByRef xStep As Double, _
ByRef yStep As Double)
Dim iter As Long
Dim xPos As Double
Dim yPos As Double
yPos = yPosInitial
xPos = xPosInitial
Debug.Print "xPos", "yPos"
For iter = 1 To iterations
Debug.Print xPos, yPos
' your code goes here
If (iter Mod newColAfter = 0) Then
yPos = yPos + yStep
xPos = xPosInitial
Else
xPos = xPos + xStep
End If
Next iter
End Function
我有一个在 visio 绘图上自动生成矩形的循环,但我需要有脚本来自动排列它们,因为我知道我在标题框下手动重新排列矩形时录制了一个宏。但是我的矩形计数不断变化,因为我的 if 语句的结果不断变化,因为我的数据不断变化。我需要我的循环开始在标题框下以六个或七个矩形的列绘制它们。
For I = 1 To WS_Count
Set vsoShape =
Application.ActiveWindow.Page.Drop(Application.DefaultRectangleDataObject,
aoffset, boffset)
vsoShape.Text = ActiveWorkbook.Worksheets(I).Name
aoffset = aoffset
boffset = boffset + 0.75
Dev_Count = Dev_Count + 1
ActiveDocument.DiagramServicesEnabled = DiagramServices
Next I
我需要能够设置一个起始位置,以开始将矩形放在标题矩形下方,每六到七个矩形创建一个新列。谢谢
每次 I
被您想要的水平形状数整除时增加 aOffset...
您可以使用 Mod Operator If (iterator Mod runEveryXIterations = 0) Then ...
下面的例子应该能理清思路,代码不是你需要的,但你应该能理解思路:
Option Explicit
Public Sub printXY()
xyDistribute 10, 3, 0, 0, 0.75, 1.5
End Sub
Private Function xyDistribute(ByRef iterations As Long, _
ByRef newColAfter As Long, _
ByRef xPosInitial As Double, _
ByRef yPosInitial As Double, _
ByRef xStep As Double, _
ByRef yStep As Double)
Dim iter As Long
Dim xPos As Double
Dim yPos As Double
yPos = yPosInitial
xPos = xPosInitial
Debug.Print "xPos", "yPos"
For iter = 1 To iterations
Debug.Print xPos, yPos
' your code goes here
If (iter Mod newColAfter = 0) Then
yPos = yPos + yStep
xPos = xPosInitial
Else
xPos = xPos + xStep
End If
Next iter
End Function