text boxes

L

Lous

I have an application that generates its output as a Word file. However, the
Word file is comprised of many individual text boxes. How can I combine the
boxes to produce a normal word document without text boxes?
 
G

Graham Mayor

If they are text boxes and not frames then

Sub ExtractFromTextBoxes()
Dim aShape As Shape
Dim sSource As Document
Dim sTarget As Document
Application.ScreenUpdating = False
Set sSource = ActiveDocument
Set sTarget = Documents.Add
sSource.Activate
With ActiveDocument
For Each aShape In .Shapes
If aShape.Type = msoTextBox Then
With aShape
If .TextFrame.HasText Then
.TextFrame.TextRange.Copy
sTarget.Activate
Selection.Paste
sSource.Activate
End If
End With
End If
Next aShape
sSource.Close SaveChanges:=wdDoNotSaveChanges End With
Application.ScreenUpdating = True End Sub

http://www.gmayor.com/installing_macro.htm

will extract the text to the main document. It will not format the document.
You will have to do that yourself.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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