每当我尝试调试或运行程序时,如果遇到错误,VBE(Autocad)不会显示错误所在的行,而不像其他IDE,它曾经在这条线上,并以黄色突出显示。另外,滚动不起作用。我知道我应该安装插件,但我无法帮助自己。 在autocad中调试VBA ide不显示错误的位置
Option Explicit
Sub Test()
'Declarations
'Opened Document
Dim acDocu As AcadDocument
Set acDocu = ThisDrawing.Application.ActiveDocument
'Select on screen
Dim acSelectionSet As AcadSelectionSet
Set acSelectionSet = ThisDrawing.SelectionSets.Add("SjjEffffT")
acSelectionSet.SelectOnScreen
'Manipulating in loops for finding group names having objects selected
Dim entity As AcadEntity
Dim entityhandle() As String
Dim Grp As AcadGroup
Dim groupname() As String
Dim i As Integer
i = 0
Dim j As Integer
j = 0
Dim temp As Integer
temp = 0
Dim GrpEnt As AcadEntity
Dim grpenthandle As String
Dim entity_count As Integer
'Dim entity_array As Variant
entity_count = acSelectionSet.Count
ReDim entityhandle(entity_count)
ReDim groupname(entity_count)
For Each entity In acSelectionSet
'entity_array = entity
entityhandle(i) = entity.Handle
For Each Grp In ThisDrawing.groups
For Each GrpEnt In Grp
grpenthandle = GrpEnt.Handle
If entityhandle(i) = grpenthandle Then
If temp = 0 Then
groupname(j) = Grp.Name
Debug.Print "Group in selection:" & groupname(j)
j = j + 1
End If
End If
temp = temp + 1
Next
temp = 0
Next
i = i + 1
Next
'Copying the objects and pasting into new drawing
Dim acDocto As AcadDocument
Dim file_name As String
'file_name = InputBox("Enter the file name along with full path and extension")
file_name = "D:\PI_Tool_files_3223\D00440023new.DWG"
Set acDocto = Documents.Open(file_name)
Dim acObject As AcadObject
Dim retvalue As Variant
retvalue = acDocu.CopyObjects(entityhandle, acDocto.ModelSpace)
acSelectionSet.Delete
End Sub
该代码是上述写入。但我认为问题与加载项,因为我无法调试。
没有代码,任何答案都是黑暗中的刺。 – Gareth
@Gareth嘿,我的主要问题是调试,因为我无法得到确切的线,它显示错误。可能是因为插件。不知道! – Divyanshu
发生这种情况是因为VBA引擎无法在库上找到对象和方法,所以当它尝试运行该方法时,会引发错误。这就是为什么你不能看到它发生的地方。例如,你可以创建另一个子程序并调用你的test()例程。 –