VBA键未找到错误
你好我将以下代码从帮助文件粘贴到新的。dvb文件并运行它。我过去工作很好。目前它给了我一个错误(如下所示)。以前它工作得很好。我重新安装了ACAD和VBA enabler。还是一样。不知道该怎么办。提前感谢您提供的任何有益建议。
~罗伯特
Sub RemoveMyLayer()
On Error Resume Next
'' Get the layer "MyLayer" from the Layers collection
Dim ABCLayer As AcadLayer
Set ABCLayer = ThisDrawing.Layers.Item("MyLayer")
'' Check for an error, if no error occurs the layer exists
If Err = 0 Then
'' Delete the layer
ABCLayer.Delete
'' Clear the current error
Err.Clear
'' Get the layer again if it is found the layer could not be removed
Set ABCLayer = ThisDrawing.Layers.Item("MyLayer")
'' Check for error, if an error is encountered the layer was removed
If Err <> 0 Then
ThisDrawing.Utility.prompt "'MyLayer' was removed"
Else
ThisDrawing.Utility.prompt "'MyLayer' could not be removed"
End If
Else
ThisDrawing.Utility.prompt "'MyLayer' does not exist"
End If
End Sub
欢迎来到罗伯特。
你试过调试选项吗? 使用F8逐行运行宏 再次感谢。我真的很感谢你的帮助。当我逐行运行代码时,它会出现以下错误。
这就好像“出错时继续下一步”的说法没有得到解释。
1.您的绘图不是名为“MyLayer”的图层
2.在VBA编辑器put选项的设置中:
未处理错误时中断
啊。。我想我可能已经解决了。我选择了对话框上的选项。。。
工具>选项>常规>错误捕捉>“未处理错误时中断”
它似乎正在与其他代码一起工作,并且没有发生错误。。。然而
再次感谢
~罗伯特 刚刚看到马拉托维奇的回复。这就是决心。 好的
在VBA中-此设置为默认值。
祝你好运
页:
[1]