Google Answers Logo
View Question
Q: In Micorosft Word - How to create a replacable text item ( Answered 4 out of 5 stars,   5 Comments )
Subject: In Micorosft Word - How to create a replacable text item
Category: Computers > Software
Asked by: jstampf-ga
List Price: $5.00
Posted: 26 Oct 2005 17:17 PDT
Expires: 25 Nov 2005 16:17 PST
Question ID: 585395
Using Microsoft Word, is it possible to create some kind of place
holder field, for example: {car_make} that can then have some text
assigned to it, for example: Chevrolet, and then all of the places
that this special place holder field appears in the document will then
display Chevrolet automatically.

Request for Question Clarification by pafalafa-ga on 26 Oct 2005 17:25 PDT
I generally do this sort of thing with the Find and Replace command (ctrl-F).

Are you familiar with this?  Is there any reason why it wouldn't work for you?


Request for Question Clarification by pafalafa-ga on 26 Oct 2005 17:27 PDT
In case you don't know what I mean, just put in some place holder text
-- say XXX -- and then find and replace all instances of XXX with
Chevrolet...give it a try.
Subject: Re: In Micorosft Word - How to create a replacable text item
Answered By: maniac-ga on 26 Oct 2005 18:57 PDT
Rated:4 out of 5 stars
Hello Jstampf,

Based on what you describe, I suggest you use a "field" that refers to
a document variable.

There are a few steps you take to use this, but once set up, can be
relatively easy to change car_make and update all references.

[1] First, we will create a "Document Variable". Use the menu
  Tools -> Macro -> Visual Basic Editor
and Visual Basic will start up / cover your document window. In Visual
Basic use the menu
  View -> Immediate Window
and enter something like this in that window:
  ActiveDocument.Variables.Add Name:= "car_make", Value:= "Chevrolet"
Repeat (with different variable names / values) if you need more than
one variable. When all such variables are defined, you can "Close and
Return to Microsoft Word" to return to the document.

[2] At each place you want to refer to the car_make, use the menu
  Insert -> Field
and a window will pop up to set the type of field reference. In the
entry field (titled "field codes"), enter
  DOCVARIABLE "car_make"
and then OK.

At this point, depending on your settings in Word, you will either see:
in that location or something like:
The first one is how the value will appear when normally viewed or
printed. The second one is if your preferences are to show field

Repeat the second step for each variable to be referenced.

To update the value, you have to go back into Visual Basic, use the
Immediate window with a command like this:
   ActiveDocument.Variables("car_make").Value = "Ford"
(repeat for each variable to change...)
and when back in Word, you can update the fields in one of the following ways:

[1] Select the field and right click/ bring up the menu and select "Update Field".

[2] Select the entire file and right click / bring up the menu and
select "Update Field". This does the updates for the whole file.

[3] In your preferences, select the printing options and "Update
Field" when printing. That way, the fields will be updated
automatically each time you print the file. [I use this when I have
fields in a header or foooter for date and time type fields]

You may have a keyboard shortcut for Update Field; on my system, the
F9 key does that as well.

To find more information about this capability search Word help with
phrases such as
  field code
  document variable

search Visual Basic help with phrases such as
  document variable
(I got the syntax by selecting the Document Variables object help entry)

or on the web with phrases like
  microsoft word document variable field
to find pages like
which goes into several options for field values. For example, it
suggests using AutoText instead of Document Variables - you may find
this easier to use in your case.
which uses a macro and document variables to automate the recording of
the number of copies printed.

If any part of the answer is unclear or you need some part expanded -
please make a clarification request.

Good luck with your work.
jstampf-ga rated this answer:4 out of 5 stars
This seems like a viable solution - although I was hoping it would be
a native feature of word and not require macro programming.  It seems
such a basic feature I'm surprised it's not built in to the GUI!  I
will attempt to code an extension to the GUI to avoid requiring other
users to code their replacement text.  Wish me luck!  (I have
extensive experience coding excel macros but no experience with word
macros or the word object model)

Subject: Re: In Micorosft Word - How to create a replacable text item
From: insolent-ga on 26 Oct 2005 18:04 PDT
I'm not exactly sure what you are asking for, but maybe a macro that
would automatically type out the entire word with you only having to
press a shortcut button or buttons would help you?  Go to tools,
macro, record new macro.  Assign macro to keyboard.  Assign the macro
to shortcut key by typing in whatever you want to be able to press in
place of the whole word for example Ctrl+Q in 'press new shortcut
key', then hit 'assign' then close.  The little box with the pause and
stop buttons should appear.  Just type out what you want to type out
like the word 'Chevrolet' then hit the square stop button.  Now every
time you hit 'Ctrl' and 'q' together, the word 'Chevrolet' will be
typed out for you.  You would have to create a new macro for every car
or word you want to be typed out.
Subject: Re: In Micorosft Word - How to create a replacable text item
From: pintado-ga on 26 Oct 2005 23:43 PDT
the Find and Replace function seems to me as though it would be far
easier than a two-page how-to, but you know - whatever ;)
Subject: Re: In Micorosft Word - How to create a replacable text item
From: jstampf-ga on 27 Oct 2005 05:43 PDT
I appreciate the input from everyone.  The find+replace is not a good
solution for two reasons (1) you can't go backwards, ie if i replace
all 'X's to 'Y's and then later want to use 'Z' instead of 'Y' I
can't.  (2) I want something friendlier and more formal than S+R for
the users who will be entering the text to pouplate the fields with.
Subject: Re: In Micorosft Word - How to create a replacable text item
From: maceo24-ga on 27 Oct 2005 06:48 PDT
There is a fairly simple feature to do this, built-into Word.  Just go
to the help area and look up "use mail merge to create form letters". 
With this, you have fields that are replaced with choices of variable.
Subject: Re: In Micorosft Word - How to create a replacable text item
From: mydog38-ga on 08 Nov 2005 06:35 PST
The field solution described above is essentially what you need--and
it can be used WITHOUT any VB macros --- all within the UI, as

To define your field, let's call it CarMake, go to File->Properties,
and select the Custom tab.  Enter CarMake in the Name box, select Text
as the Type and enter any value (e.g. "Chevrolet") in the Value field.
 Then, click "Add" and "OK".  Now you have created a custom property
for your document called CarMake.

Whenever you want the property to show in your document, select
Insert->Field.  In the Field Names box, select "DocProperty."  This
will bring up a Property list, which will include "CarMake."  Select
that and uncheck "Preserve formatting during updates."  Then click

Now all you have to do is go back to the File->Properties (Custom) tab
to change the value to "Ford" or whatever as needed, and Select-All,
F9 the document to update the new value.

Let me know if this is closer to what you wanted.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  

Google Home - Answers FAQ - Terms of Service - Privacy Policy