刚刚看到,这样试试: Dim acadApp As AutoCAD.AcadApplication Dim AcadDoc As AcadDocument Private Sub Command1_Click() '隐藏自身窗体,以把控制权交给CAD Me.Hide StartAcad ‘激活CAD窗体进行操作 AppActivate (acadApp.Caption) Dim OBJdoc As AcadText Dim ptPick As Variant Set AcadDoc = acadApp.ActiveDocument AcadDoc.Utility.GetEntity OBJdoc, ptPick, "请点选文本" Text1.Text = OBJdoc.TextString '重新显示自身 Me.Show End Sub Sub StartAcad() Dim acadApp As AcadApplication’已经定义为模块级变量了,这句必须去掉! On Error Resume Next Set acadApp = GetObject(, "AutoCAD.Application.16") If Err Then Err.Clear Set acadApp = CreateObject("AutoCAD.Application.16") If Err Then MsgBox Err.Description Exit Sub End If End If MsgBox "Now running " + acadApp.Name + " version " + acadApp.Version End Sub
|