Word data extraction.

K

Ken

Posted this the other day, then realized I didn't give
quite enough information.

I have a VB program that extracts data from a word
document. Most of the data are in tables, so it is
relatively easy to get to. However, I have four values
that fall outside of the table. For example:

Table1 Here

$variable1$

Table2 Here

Here's a sentence: $variable2$


The $ signs delimit where some proprietary software pulls
data into the word document. When that software is done
with its thing, the $ signs and label in between are gone
and what was in the data stream replaces them. Then the
document is saved off as a .rtf file. I can use vb
easily enough to get what's in the tables. Is there some
way to point it to the value that replaces the $...$
variables?

Thanks.
 
J

Jay Freedman

Hi, Ken,

I'll give you a highly doubtful "maybe" on that...

You need some way to locate the pieces of text to extract. There are a
number of ways that might be possible, but you'll have to look at your
documents and decide which one -- if any -- is feasible. These are listed in
order of my estimate of probable feasibility:

- By bookmarks: If the document is based on a template that contains
bookmarks covering the $variable1$ and $variable2$ placeholders plus the
space on either side, you can extract the text of the bookmark's range. (If
you don't include the spaces, it's likely that the bookmarks will be removed
along with the placeholders.)
- By style: If the variable placeholders are formatted in a unique style,
you can use the Find method to extract each item that has that style.
- By position: If they're always in the same place relative to the table,
you can manipulate a range object or the Selection to cover the correct
areas.
- By tagging: If you could somehow arrange to have the $ signs left in
place, or replaced by some other recognizable character(s), you can use a
wildcard Find for the delimiters and grab whatever is between them.
- By content: If you know what specific text may replace variable1 and
variable2, you can use the Find method.
 

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