extract strings in tables and paragraphs

S

Susan Kong

HI,

I'm using VC++6.0 for Word automation, and I'd like to extract strings in
both tables and paragraphs. Seems strings in tables are extracted twice
(from paragraph and table object) if these strings are followed up with a
return carriage.

How can I avoid this?

thanks in advance.

Susan
 
C

Cindy M -WordMVP-

Hi Susan,
I'm using VC++6.0 for Word automation, and I'd like to extract strings in
both tables and paragraphs. Seems strings in tables are extracted twice
(from paragraph and table object) if these strings are followed up with a
return carriage.
You shouldn't need to extract the information from the table separately.
Just loop through the paragraphs, that should pick up everything in tables,
as well (but not in graphics objects).

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
S

Susan Kong

Thanks for reply,Cindy.

I tried to extract text by looping through the paragraphs, yes it works for
tables almost. However, paragraphs are marked with return carriage (to see
this return symbol, go Tools->Option->View->Formatting marks->Select "All"),
so if the text in table has no return symbol followed by, it can't be
extracted. That's my biggest concern.

Any suggestion?

Susan
 
C

Cindy M -WordMVP-

Hi Susan,
I tried to extract text by looping through the paragraphs, yes it works for
tables almost. However, paragraphs are marked with return carriage (to see
this return symbol, go Tools->Option->View->Formatting marks->Select "All"),
so if the text in table has no return symbol followed by, it can't be
extracted. That's my biggest concern.
Start with an empty "test" document. Press ENTER once (to create an empty
paragraph). Insert a simple table. Type some text in the empty paragraph and
in the first table cell.

Now get the text for
ActiveDocument.Paragraphs(1).Range.Text
and
ActiveDocument.Paragraphs(2).Range.Text

Compare them very carefully. You'll find that the first returns a Chr$(13)
(paragraph mark = /r = carriage return in C-languages) at the end. The second
will have two additional characters: Chr$(13) + Chr$(7). The first is the
paragraph mark you're concerned about. The end-of-cell marker in the table
contains a "hidden" paragraph mark. It also contains an "end-of-cell"
character (the Chr$(7)). Basically, this is a pointer for Word to the internal
"table" that contains the cell formatting information. In order to make the
two paragraphs "equal" you'll need to cut off this last character from the
last paragraph in the cell. If you check the string for the presence of
Chr$(7) and, if it's found, remove it, you should be fine :)

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
S

Susan Kong

Thanks for the very professional explaination! I tried, and it works exactly
as you described.

Susan
 

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