How would I import all the text from an Autocad drawing to an Access database? I have some code that works with word and autocad but I need to get the text in access.
I want the text to be in access. I will add a drawing number to each set allowing it to be searchable. Here's the code. I got it from the Autocad Forum.
script for acad text to microsoft word?
Open MS Word and then open Visual basic from the toolmenu: “Functions“, “Macros” ,
“Edit in Visual Basic”.
Insert a “Modul” in VBA from the toolmenu “Insert”. (In the window “Project Explorer” in VBA, you can select if you want to apply the Modul to MS Word for ever, or just to the opened document)
Copy the following code into your new Modul.:
Private AC As Object
Private mspace As Object
Sub Transfer_ACText_To_Word()
Dim Value As Object
Set AC = Nothing
On Error Resume Next
Set AC = GetObject(, "AutoCAD.Application"
If Err <> 0 Then
Set AC = CreateObject("AutoCAD.Application"
MsgBox "You have to open a dwg. file in AutoCad " & _
"first and let the commandline stay empty"
Exit Sub
End If
AC.Visible = True
Set doc = AC.ActiveDocument
Set mspace = doc.ModelSpace
For Each Value In mspace
With Value
If StrComp(.EntityName, "AcDbMText", 1) = 0 Or StrComp(.EntityName, "AcDbText", 1) = 0 Then
Selection.TypeText Text:=.TextString
Selection.TypeParagraph
End If
End With
Next Value
MsgBox "Finished"
End Sub
You can now close VBA.
Open AutoCad and the drawing that contains the text you want to export.
Move to MS Word.
Choose “Macros…” from the toolmenu: “Functions“, “Macros”
A dialogbox appears where you select “Transfer_ACText_To_Word”
Regards to you Kristina
This code works great. I have a lisp command that does basically the same thing except it exports it as a text file which I then import into access manually. I have about five hundred drawings I need to do thid to so I thought maybe I could automate it.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.