Pasting into a search and replace

B

Ben K. Bullock

Thanks very much for answers to my previous enquiry about pasting into the
search and replace box. After having read this newsgroup, it struck me to
use a "bookmark" plus "REF" to search and replace repeated text so that it
can be changed easily.

Is it possible to paste the contents of a "REF" into the "replace" field,
and if so how do I do it? The obvious thing doesn't seem to work.

Thanks very much for any help with this.
 
S

Suzanne S. Barnhill

Copy your field to the Clipboard and use ^c (Clipboard contents) in the
"Replace with" box.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
B

Ben K. Bullock

Suzanne S. Barnhill said:
Copy your field to the Clipboard and use ^c (Clipboard contents) in the
"Replace with" box.

Thank you ever so much for your help. However, when I do that, I seem to get
the current value of the field rather than the field itself.

I want to do a search and replace in the following way:

The current text is

"XYZ blah blah XYZ blah jah blah XYZ"

but I want to make XYZ into a field with the value ABC, so it looks like

"ABC blah blah ABC blah jah blah ABC",

but all the ABCs are actually fields, like { DocProperty XYZ }, rather than
the value of the field, ABC. Does it make sense? I can't seem to get the
field itself into the "Replace with" box, only the current value.

Thanks again for any help with this.
 
S

Suzanne S. Barnhill

Is this still true even if the field code is displayed when you copy it?
When I try this, with a newly created DATE field, I get what looks like no
result (the "Find what" text deleted) until I Select All and F9 to update
the fields; then I get today's date for every "lorem" I replaced in my lorem
ipsum text. If I display field codes, I see a DATE field for each
replacement.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
B

Ben K. Bullock

Thank you again for the help.

I put the following text into Word:

XYZ blah blah XYZ blah jah blah XYZ

Then I made a DocProperty XYZ with value ABC.

Then, after that text, I did "insert", "field", "DocProperty XYZ". This is
inserted correctly as a grey box showing ABC. Now the document looks like
this:

XYZ blah blah XYZ blah jah blah XYZ

ABC

Following this, I get the binoculars window, and do search and replace. In
the top window I type "XYZ", then I go to the field ABC, select it with the
mouse, press control-C, click on the lower entry of the search and replace
window, and press control-V to paste. Then I "replace all" and the document
looks like this:

ABC blah blah ABC blah jah blah ABC


ABC

But the ABCs on the top are not fields; even if I change the value of the
DocProperty XYZ, they don't change after I update fields.

If I do a similar thing, copying and pasting without updating the field, so
it just shows { DocProperty XYZ }, then I just get nothing at all:

" blah blah blah jah blah "

Even after I update the fields, nothing appears where the XYZs were.

I've had to do a lot of these fields in my document, and my current method
is to replace the text XYZ with "DocProperty XYZ" and then search for all
the "DocProperty XYZ"s and make them into a field using the F9 button.
Unfortunately there are rather a lot of them and it would be nice to be able
to automate this process somehow.

Thanks for any suggestions.
 
S

Suzanne S. Barnhill

I don't know what I'm doing differently:

1. I create a custom document property named XYZ, with the value ABC.

2. I insert a DocProperty field using the Insert Field dialog: { DOCPROPERTY
XYZ \* MERGEFORMAT }

3. With the field code displayed, I select the entire field (including the
field braces) and copy.

4. I insert a batch of lorem ipsum text.

5. I search for "lorem" and replace with ^c.

6. Every "lorem" is replaced with { DOCPROPERTY XYZ \* MERGEFORMAT }.

7. When I toggle field codes, every "lorem" has been replaced by ABC.

8. If I change the value of XYZ to DEF and update fields, I get DEF where I
had ABC.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
B

Ben K. Bullock

Thank you for your very kind reply again.

Suzanne S. Barnhill said:
I don't know what I'm doing differently:

1. I create a custom document property named XYZ, with the value ABC.

2. I insert a DocProperty field using the Insert Field dialog: {
DOCPROPERTY
XYZ \* MERGEFORMAT }

3. With the field code displayed, I select the entire field (including the
field braces) and copy.

4. I insert a batch of lorem ipsum text.

5. I search for "lorem" and replace with ^c.

6. Every "lorem" is replaced with { DOCPROPERTY XYZ \* MERGEFORMAT }.

I think maybe the difference is here, you didn't replace them all at once,
you replaced them one by one using control-C for each instance.

So, my question is, is it possible to replace them all at once, without
repeated search and replacement?
 

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