类模块eventclassmodule里的代码: Option Explicit Public WithEvents Doc As AcadDocument Public Sub AcadDocument_ObjectModified(ByVal obj As AcadObject) MsgBox "A " & TypeName(object) & " was just modified!" End Sub
窗体模块中的代码: Option Explicit Dim acadApp As AcadApplication Dim X As New EventClassModule
Private Sub Form_Load() On Error Resume Next Set acadApp = GetObject(, "AutoCAD.Application") If Err Then Err.Clear Set acadApp = CreateObject("AutoCAD.Application") If Err Then MsgBox ("²»ÄÜÔËÐÐAutoCAD2004,Çë¼ì²éÊÇ·ñ°²×°ÁËAutoCAD2004") Exit Sub End If End If acadApp.Visible = True acadApp.WindowState = acMax
X.Doc = AcadApplication.ActiveDocument Dim lineObj As AcadLine Dim startPoint(0 To 2) As Double Dim endPoint(0 To 2) As Double