我把"ThisDrawing"改为"acadapp.activeDocument "就可以了。不过不懂原理,请老师讲解下,或者该看什么帮助?
Dim AcadApp As AcadApplication
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 ("不能运行AutoCAD ,请检查是够安装了AutoCAD")
Exit Sub
End If
End If
AcadApp.Visible = True
End Sub
Private Sub Command1_Click()
Dim pt As Variant
pt = AcadApp.activeDocument.Utility.GetPoint(, "请指定一点:")
'x坐标值显示在TEXT1中,Y坐标值显示在TEXT2中:
Text1.Text = pt(0)
Text2.Text = pt(1)
zoomall
End Sub
如果你有耐心,好好看看http://bbs.mjtd.com/thread-111783-1-1.html
Public Function ThisDrawing() As AcadDocument
If Not (objCad Is Nothing) Then Set ThisDrawing = objCad.ActiveDocument
End Function
以上函数,使得vb6与VBA代码通用!!!