A way to autochange text

G

gjaynes

We have a block of text that is used many times in a Word
document. If after 30 pages of using this block of text
over and over we want to change the words. Is there
anyway to automatically change the block of text? (too big
for replace function.

Example:
Quote 101, section 2
Reference block abc with steel galvanized washers.....
(+100 words)

Quote 101, section 3
Reference block abc with steel galvanized washers.....
(+100 words

....... Now after using the block for 60 pages need to
change the verbage.

Would like to store in a variable or something.

Any ideas?
 
M

Mark Tangard

Hi gjaynes,

Well, if you want to change it just once and you're sure you
won't need to do it again (see further below if otherwise),
what I would do is:

1. A Find/Replace that changes the beginning of the text
(enough of it to make the search grab only that text) to
itself preceded by a unique string

2. Another Find/Replace that changes the *end* of the text
(enough of it to make the search grab uniquely), *followed*
by a second unique string.

3. A third Find/Replace, with wildcards on, that replaces:

first_unique_string*second_unique_string

with your new text -- or, if your new text is also too large
for the Find dialog, with something smaller but unique, so
that you could do another series of Find/Replaces to fill it
in in steps. (The asterisk in a wildcard search matches any
number of characters.)

BUT.... if there's a chance you might need to do this again,
what I'd probably do is:

1. Store your new block of text as an AutoText entry named,
say, newblock.

2. Do 1 and 2 in the previous example as shown.

3. Using a wildcard search, change

first_unique_string*second_unique_string

to something unique AND short. THEN....

4 Using a *macro* -- since this can't be done by using the
Find/Replace dialog -- change the new unique short text string
to an AUTOTEXT field referencing the AutoText you built above,
i.e., {AUTOTEXT newblock}. Then press ALT+F9 if necessary to
undisplay the field codes.

This'll allow you to change the text again simply by redefining
the AutoText entry, selecting the whole document, and pressing
F9 to update the fields.

The only real hurdle would be writing the macro to insert the
{AUTOTEXT} fields. Assuming your new unique short text string
is, say, 'grokzeeb', this would do it:

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "grokzeeb"
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWildcards = False
Do While .Execute
ActiveDocument.Fields.Add Range:=Selection.Range, _
Type:=wdFieldAutoText, Text:="newblock", _
PreserveFormatting:=False
Loop
End With


Hope this helps.
 

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