Hierarchy of Objects in Word

G

George B

Running Word 2000, I have a document with perhaps a half dozen paragraphs,
with two tables interspersed among the paragraphs. If I have a loop:
For Each p in ActiveDocument.Paragraphs
I cycle through all paragraphs, both inside and outside the tables. I can
also:
For Each t in ActiveDocument.Tables
and cycle through the tables. Is there some property which tells me where
the tables occur among the top-level paragraphs? How do I refer to the
paragraph before a table?

I am trying to write a customized conversion of all tables to text. I am
successfully accessing the cells of the table and generating the replacement
text, but have not been able to generate a new paragraph to store the new
text.
 
D

Dave Lett

Hi,

Is there a reason you can't use .ConvertToText?

Dim lTbl As Long
For lTbl = ActiveDocument.Tables.Count To 1 Step -1
ActiveDocument.Tables(lTbl).ConvertToText
Next lTbl

HTH,
Dave
 
G

George B

Hi, Dave

I've tried ConvertToText but this doesn't do what I need. Some of the
table cells have very long entries, requiring many lines to display.
ConvertToText puts all of the entry on one line; I'm trying to format each
row into multiple lines which look like the original display.

George B
 
H

Helmut Weber

Hi George,
Is there some property which tells me where
the tables occur among the top-level paragraphs? ???

How do I refer to the paragraph before a table?
In case there is a paragraph before a table:
With ActiveDocument.Tables(1).Range
MsgBox .Paragraphs.First.Previous.Range.Text
End With

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
D

Dave Lett

Hi George,

Let me suggest an alternative: instead of trying to show the multiple lines,
can you format the paragraph so that its right indent gives you the lines
that you want to preserve?

HTH,
Dave
 

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