Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

script for acad text to microsoft word? 1

Status
Not open for further replies.

kristina

Instructor
Apr 6, 2001
11
0
0
US
Hello,
Does anyone know of a script or anything of the sort that would be a short cut to get three "d" size papers worth of text from Autocad into a word document for specs? I believe there used to be something availabe for ACAD 12 or 14... Any help would be appreciated!

Thanks in advance!

Kristina :)
 
Hey Kristina

I really hope that I understand your question correct. I understand it like you want to export all the single line text and multiline text from an AutoCad drawing….?
If so, I would do some coding in MS Words Visual Basic (VBA) , simply because I cant remember any lisp that will do your job.
Steps:
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(&quot;AutoCAD.Application&quot;)
MsgBox &quot;You have to open a dwg. file in AutoCad &quot; & _
&quot;first and let the commandline stay empty&quot;
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, &quot;AcDbMText&quot;, 1) = 0 Or StrComp(.EntityName, &quot;AcDbText&quot;, 1) = 0 Then
Selection.TypeText Text:=.TextString
Selection.TypeParagraph
End If
End With
Next Value
MsgBox &quot;Finished&quot;
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
Write back on troubles with the code or if I totally have misunderstood something seriously (-:
 
I think this will handle it, I'll be working with my customer on this and will let you know if there are any problems with it or if it works right for him. So far, I tried it and it seems to test fine for me! Thanks so much! Also, just in case anyone else is interested in this, on my version of MS Word, the macros is under &quot;tools&quot; for me instead of &quot;function&quot;. I didn't see any place for me to tell it to be in &quot;this documnet&quot; or in all of Word.

Thank you so much for your time! :-D

Kristina
 
I just wanted to let you know it worked wonderfully! For anyone else wanting to use this, If you have a title block in the .dwg file with text, you might want to block out only the text you want to come into Word. There's still a bunch of editting, but *WOW* it's awesome! ;-)

Thank you again, KBBJ!

Kristina
 
It’s a pleasure to get replies like yours Kristina.

KBBJ
 
KBBJ,

Is it possible to make this work from Autocad to Access. By the way the code to word it awsome. It blew my mind when I ran it.


Praxden
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top