- Dim myAcadApp As AutoCAD.AcadApplication, SS As AcadSelectionSet, FT(0) As Integer, FD(0) As Variant
- Dim BF As AcadBlockReference, AF As AcadAttributeReference, V1 As Variant, V2 As Variant
- On Error Resume Next
- Set myAcadApp = GetObject(, "Autocad.Application")
- If Err <> 0 Then
- Err.Clear
- Set myAcadApp = CreateObject("Autocad.Application")
- If Err Then
- MsgBox Err.Number & ":" & Err.Description
- Exit Sub
- End If
- End If
- With myAcadApp
- .WindowState = acMax
- .Visible = True
- AppActivate "AUTOCAD"
- With .ActiveDocument
- Set SS = .SelectionSets.Add("SS")
- FT(0) = 0
- FD(0) = "INSERT"
- SS.SelectOnScreen FT, FD
- For Each BF In SS
- V1 = BF.GetAttributes
- For Each V2 In V1
- Set AF = V2
- If AF.TagString = "A" Then
- '此处把 AF.TextString 属性填入EXCEL单元格
- End If
- Next
- Next
- SS.Delete
- End With
- End With
|