How to extract text from text boxes only?

G

Guest

I have a very long document with a large number of text boxes spread
throughout it. I need to extract only the text from these textboxes, and
ignore everything else. Is there any way to do this automatically? I'm
assuming I'll have to use a third party tool, as I can't see anything in Word
that will help me do it.
Thanks!

Evan
 
M

macropod

Hi Evan,

You can use a macro like the attached to extract the text attached to all
shapes (just in case you have added text to some other autoshapes)from the
active document and paste it into the end of the document (you didn't say
where you want it to go). From there you can cut/copy & paste the text to
wherever else you want.

Sub XtrctTxt()
Dim shp As Shape
Dim MyText
For Each shp In ActiveDocument.Shapes
With shp.TextFrame
If .HasText Then
MyText = .TextRange.Text
With Selection
.EndKey Unit:=wdStory
.InsertAfter MyText
End With
End If
End With
Next
End Sub

For info on how to run macros, see:
http://www.mvps.org/word/FAQs/MacrosVBA/CreateAMacro.htm


Cheers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top