在模块中
Option Explicit Dim acadApp As Object Dim Preference As Object Dim acaddoc As Object Dim Paspace As Object Dim MoSpace As Object
在窗体中
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 Err.Description Exit Sub End If End If
acadApp.Visible = True Set Preference = acadApp.Preference Set acaddoc = acadApp.ActiveDocument Set MoSpace = acaddoc.ModelSpace Set Paspace = acaddoc.PaperSpace
On Error Resume Next acaddoc.SelectionSets("sel").Delete Set sl = acaddoc.SelectionSets.Add("sel")
Set sl = acaddoc.ActiveSelectionSet
Text1 = sl.Count
End Sub 我测试可以,,,好象函数是区分大小写的,
|