Identify and mark numbers at the beginning of paragraphs - but not headings

A

Alex Wenzel

Hi group,

my problem (Word 2003):

I have to identify all numbers that are at the beginning of a paragraph
in a word document but are *not* headings and put a marker (like
"xyzxyz") in front of the number (to prevent that any numeric character
that does not belong to a heading will ever stand at the beginning of a
paragraph; this is important for further scripting/conversion in this
case).

Headings (which shall *not* get a marker) are numbered 1., 1.1, 1.2,
2., 3., 3.1, 3.2, 3.2.1, 3.2.2, 3.3, 4. etc.

There are probably no numbers >99 in Headings (so no three-digit
numbers between periods in heading numbering), but at the beginning of
paragraphs there may be numbers that have (a) periods as thousands
separators, as these are German documents and (b) dates, which are
written "xx.xx.xxxx" here, with or without spaces.
both kinds of numbers should be treated like all other non-heading
numbers (put a marker before the first digit at the beginning of the
paragraph).

I can't use paragraph styles for identification, because they're not
reliably there.

All this should be done by a macro.
Actually, I don't have a clue about VBA, but I can copy/paste, and I
have to solve this - fast!

Can someone help?

TIA
Alex
 
A

Alex Wenzel

Doug said:
See the article "Finding and replacing characters using wildcards" at:

http://www.word.mvps.org/FAQs/General/UsingWildcards.htm

Thanks, this article helped me to find out how to do this by
search/replace - in five turns...

A.) Mark Headings
1st Level:
Search: (^13)([0-9]{1;2}).([!0-9])
Replace all: \1XXX\2.\3
2nd Level:
Search: (^13)([0-9]{1;2}).([0-9]{1;2})([!.0-9])
Replace all: \1XXX\2.\3\4
3rd Level (and subsequent levels):
Search: (^13)([0-9]{1;2}).([0-9]{1;2}).([0-9]{1;2})([!0-9])
Replace all: \1XXX\2.\3.\4\5

B.) Mark all other numbers at the beginning of paragraphs
Search: (^13)([0-9])
Replace all: \1YYY\2

C.) Revert A.
Search: (^13)(XXX)([0-9])
Replace all: \1\3

(Note that these statements are with semicolons instead of commas
because it is a German version).

This looks like a lot of work. How to combine that into a macro (and
hopefully also catch numbers in tables, which these search-replace
passes seem not to do)?
 

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