Loopy Loop发送给我Loopy。。
嗨,有人能看看这段代码并发现它为什么不能正常工作吗...
基本上,这是我编写的用于修改绘图的主程序的一小部分,该部分将标题块重置回默认设置。主表单有一个显示布局的列表框,因此用户可以选择他们需要修改或重置的任何布局...
下面例程的ONLY SELECTED ONES部分的代码工作正常(从msgbox中单击否),但是选项(ALL LAYOUTS)将只执行当前布局,而不是循环遍历它们,因为它应该...
ResetTitleBlock子例程只是循环遍历标题块的属性并将它们更改为默认值...
有问题的代码是红色的。顺便说一句,layoutZ是暗淡的ACAD LAYOUT...
' DELETE REVISION DETAILS..
Private Sub cmdDELETEREVISIONS_Click()
response = MsgBox("Would you like to reset ALL titleblocks or just the selected ones?.." & vbCr & vbCr & "Click Yes to reset ALL layouts or click No to reset only selected layouts..", vbYesNoCancel, "Revision Details Editor..")
If response = vbCancel Then
Exit Sub
End If
If response = vbNo Then
' Loop through the selected layouts..
For Cx = LBound(SelectedLayouts) + 1 To UBound(SelectedLayouts)
ThisDrawing.ActiveLayout = ThisDrawing.Layouts(SelectedLayouts(Cx))
ResetTitleBlocks
Next Cx
GoTo RESETEND
ElseIf response = vbYes Then
For Each layoutZ In ThisDrawing.Layouts
ResetTitleBlocks
Next layoutZ
GoTo RESETEND
End If
RESETEND:
Unload Me
End Sub
有什么想法为什么它没有循环遍历所有绘图的布局吗?
**** Hidden Message ***** 我怀疑这与您没有将布局设置为当前布局有关。<br>您还可以使代码更友好一些,如:<br><pre>Private Sub cmdDELETEREVISIONS_Click()
response = MsgBox("Would you like to reset ALL titleblocks or just the selected ones?.." & vbCr & vbCr & "Click Yes to reset ALL layouts or click No to reset only selected layouts..", vbYesNoCancel, "Revision Details Editor..")
Select Case response
Case vbCancel
Exit Sub
Case vbNo
' Loop through the selected layouts..
For Cx = LBound(SelectedLayouts) + 1 To UBound(SelectedLayouts)
ThisDrawing.ActiveLayout = ThisDrawing.Layouts(SelectedLayouts(Cx))
ResetTitleBlocks
Next Cx
Case vbYes
For Each layoutZ In ThisDrawing.Layouts
ThisDrawing.ActiveLayout = layoutZ
ResetTitleBlocks
Next layoutZ
End Select
Unload Me
End Sub
页:
[1]