PDA

View Full Version : Loop thru the document



AK3003
11-20-2008, 12:06 AM
Friends,

I want loop thru the document (as attached FullWordTest.docx) and return each sentence/paragraph.

I tried using Paragraph object and Sentence object calls on Active Document
ActiveDocument.Paragraphs.Count and ActiveDocument.Sentences.Count returns 1 and If I drill down further Paragraph.Range.Text returns no text.

Request somebody help me in loop thru the document and return each sentence/paragraph.

Thanks in Advance.
--AK.

TonyJollans
11-20-2008, 07:55 AM
Your document consists of a load of textboxes. Textboxes are part of the shapes (in this case) so you need to work with them, something like

For Each s In activedocument.Shapes
If s.Type = msoTextBox Then
MsgBox s.TextFrame.TextRange.Sentences.Count
End If
Next

fumei
11-20-2008, 10:00 AM
The point being is that text (paragraphs and sentences) in textboxes are NOT included in the document Paragraphs collection. That is why you get the Count = 1.

You must work with the Shapes collection...as Tony mentioned.

AK3003
11-21-2008, 12:32 AM
Tony & Fumei,

It worked like a fly!!!

Thanks a ton for your help

Thanks in Advance
--AK