' 获得用户输入 Dim Pnt As Variant Dim ent As AcadEntity ThisDrawing.Utility.GetEntity ent, Pnt, "选择对象[设置(S)/删除(E)]: " If Err Then If StrComp(Err.Number, -2145320928, 1) = 0 Then ' 当输入关键字时 Dim inputString As String Err.Clear inputString = ThisDrawing.Utility.GetInput MsgBox "输入的关键字是: " & inputString Else MsgBox "选择对象出错: " & Err.Description Err.Clear End If Else ' 显示用户选定的对象类型 MsgBox "你选定的对象类型为: " & ent.ObjectName, , "明经VBA示例:GetEntity及InitializeUserInput方法" End If End Sub