Extracting text from within frames.

T

Tatumsa

Hi there,

I have been given some Word documents that have data in them that I
need to extract. However, each section of text is in its own frame.
The data is columnar (each cell being in its own frame) with form
headings.

Is there a way to extract data from the individual frames so that I
can output it to something usable? I have been playing around with
the .copy method of a Frame, and tried to look at the TextFrame object
(which I don't know how I can use). I'm a bit stumped.

I have looked in the forum for mentions of Frames but I can't find any
that fit my situation.

Thanks in advance for any help given.

Scott.
 
S

Shauna Kelly

Hi Scott

This might help:

Sub ManipulateFrames()

Dim frm As Word.Frame
Dim sFrm As String
Dim rngTarget As Word.Range

If ActiveDocument.Frames.Count > 0 Then

'You can get a reference to a frame
Set frm = ActiveDocument.Frames(1)

'You can set a variable to hold the text of
'the frame
sFrm = frm.Range.Text

'You can do things with that text
MsgBox sFrm

'You can copy the contents elsewhere
'in the document using something like this
Set rngTarget = ActiveDocument.Paragraphs.Last.Range
rngTarget.InsertAfter vbCrLf
rngTarget.Collapse wdCollapseEnd
rngTarget.FormattedText = frm.Range

End If

End Sub


Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
 
T

Tatumsa

Hi Scott

This might help:

Sub ManipulateFrames()

Dim frm As Word.Frame
Dim sFrm As String
Dim rngTarget As Word.Range

If ActiveDocument.Frames.Count > 0 Then

'You can get a reference to a frame
Set frm = ActiveDocument.Frames(1)

'You can set a variable to hold the text of
'the frame
sFrm = frm.Range.Text

'You can do things with that text
MsgBox sFrm

'You can copy the contents elsewhere
'in the document using something like this
Set rngTarget = ActiveDocument.Paragraphs.Last.Range
rngTarget.InsertAfter vbCrLf
rngTarget.Collapse wdCollapseEnd
rngTarget.FormattedText = frm.Range

End If

End Sub

Hope this helps.

Shauna Kelly. Microsoft MVP.http://www.shaunakelly.com/word











- Show quoted text -

Ahh! That's it exactly. Thanks so much :)

Scott.
 

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