Lynne:
You can use this to import text from AutoCAD to Excel as well as the
coordinates...
You'll just have to add a reference to Excel in the VBA IDE.
[code]
Option Explicit
Public intRow As Integer
Public strCell As String
' Application - Excel
Public oExcel As Excel.Application
Public oBook As Excel.Workbook
Public oSheet As Excel.Worksheet
Private Sub CreateExcel()
Dim i As Integer
Set oExcel = CreateObject("Excel.Application")
Set oBook = oExcel.Workbooks.Add
Set oSheet = oBook.Worksheets(1)
oExcel.Visible = True
End Sub
Public Sub TextToExcel()
Dim obj As AcadEntity
Dim objText As AcadText
Dim varInsert As Variant
' Create an Excel object
CreateExcel
oExcel.Cells(1, 1).Value = "TEXT"
oExcel.Cells(1, 2).Value = "X: COORDINATE"
oExcel.Cells(1, 3).Value = "Y: COORDINATE"
oExcel.Cells(1, 4).Value = "Z: COORDINATE"
intRow = 2
For Each obj In ThisDrawing.ModelSpace
If TypeOf obj Is AcadText Then
Set objText = obj
oExcel.Cells(intRow, 1).Value = objText.TextString
varInsert = objText.InsertionPoint
oExcel.Cells(intRow, 2).Value = varInsert(0)
oExcel.Cells(intRow, 3).Value = varInsert(1)
oExcel.Cells(intRow, 4).Value = varInsert(2)
intRow = intRow + 1
End If
Next obj
End Sub
[/code]
--
Matt W
The difference between genius and stupidity is that genius has its limits.
"Matt W" wrote in message
news:40ec07f4$1_3@newsprd01...
| Yeah, you're right.
| I just threw something together really quick, which is why it worked on a
| BLANK drawing with only 3 pieces of text. :)
|
| --
| Matt W
|
| The difference between genius and stupidity is that genius has its limits.
| "James Belshan" wrote in message
| news:40ebfa79$1_3@newsprd01...
| | Matt,
| | Your code would crash if there were any non-text items in modelspace.
It
| | needs to be something more like:
| |
| | dim objEnt as AcadEntity
| | > Dim objText As AcadText
| | >
| | > For Each objEnt In ThisDrawing.ModelSpace
| | If TypeOf objEnt is AcadText Then
| | Set objText = objEnt
| | > ' Insert code to export to Excel here...
| | EndIf
| | > Next objEnt
| |
| | Lynne,
| | You could use the SelectOnScreen method, with a filter on so that only
| text
| | items are selected, to get all the text in an area. Or, to use Matt's
| code,
| | you would check the .InsertionPoint of each Text item to see if it's the
| | one(s) you want.
| |
| |
| | HTH,
| | James
| |
| |
|
|