| 语法 
 object.VBE 
 object
 Application使用该属性的方法。
 VBE
 Microsoft VBE 对象; 只读VBAIDE 扩展对象。
 说明 
 该属性使你能通过AutoCAD 的对象模型访问 VBA IDE 对象。如果VBAIDE不可用,该属性将出现异常。例如,当acvba.arx 应用程序未加载时,VBAIDE 不可用。
 以下的代码行将返回当前的VBA 工程名:
 ThisDrawing.Application.VBE.ActiveVBProject.Description   
 Sub Example_VBE()
    ' This example uses the VBA IDE extensibility model to dynamically
    ' create a VBA subroutine. After running this example, see the first line of code
    ' in the VBA IDE code window to see a new subroutine. Then 
    ' remove the new subroutine before continuing.
    Dim VBEModel As Object
    Dim newRoutine As String
    
    Set VBEModel = VBE  ' Get the VBE object
    
    ' Define new subroutine to be added. This could be created dynamically from user feedback.
    newRoutine = "Sub Dynamic_Procedure()" & vbCrLf
    newRoutine = newRoutine & vbTab & "MsgBox ""New subroutine.""" & vbCrLf
    newRoutine = newRoutine & "End Sub" & vbCrLf
    
    ' Insert new subroutine
    VBEModel.CodePanes(1).CodeModule.InsertLines 1, newRoutine
    
    MsgBox "A new subroutine was added called Dynamic_Procedure."
End Sub |