下面是一个非常基本的代码段,用于将文本作为文本、多行文字或属性引用。仍需要传输到Excel的代码。
- Sub GetTextData()
- Dim varPckPt As Variant
- Dim obj As AcadObject
- Dim varMatrix As Variant
- Dim lngContext As Long
- Dim strObjName As String
- Dim strText As String
- On Error GoTo MissedPick
- ThisDrawing.Utility.GetSubEntity obj, varPckPt, varMatrix, lngContext, "Select some text: "
- On Error GoTo 0
- strObjName = obj.ObjectName
- Select Case strObjName
- Case "AcDbMText"
- Dim entMText As AcadMText
- Set entMText = obj
- strText = entMText.TextString
-
- Case "AcDbText"
- Dim entText As AcadText
- Set entText = obj
- strText = entText.TextString
-
- Case "AcDbAttribute"
- Dim entAtt As AcadAttributeReference
- Set entAtt = obj
- strText = entAtt.TextString
-
- Case Else
- strText = "No text selected!"
-
- End Select
- MsgBox strText
- Exit Sub
- MissedPick:
- MsgBox "Missed Pick!"
- End Sub
|