Using variables in MS Word?

merlin777

Well-known Member
Joined
Aug 29, 2009
Messages
1,395
Office Version
  1. 2007
I'm writing a document in MS Word which is to be customised for individuals. I realise that sounds like a job for mail merge but that's not really appropriate in this case. Each document will be customised individually as required and not in a batch.

I wondered if I could put a variable in the place of a name or phone number and then set that variable on the final page so all instances of the variable show that value.

For instance, the document might need to say:

"If you are concerned please contact your therapist, joe bloggs, on 01234 56789."

But I'm wondering if I could put:

"If you are concerned please contact your therapist, variable A, on variable B."

and then set the variables appropriately.

My instinct is to do it in excel which I know well but it's not ideal for text documents and these documents will be customised by people who can use Word but not too familiar with excel.

Any thoughts would be greatly appreciated.
 

Some videos you may like

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

merlin777

Well-known Member
Joined
Aug 29, 2009
Messages
1,395
Office Version
  1. 2007

Thanks - that get's me halfway there.

At the moment it doesn't really save any time or allow a novice user to do it. It's about as much work as putting the names in manually because of having to go through the menus.

I was hoping for a solution which allowed the user to fill in some properties at the end of the document e.g.:

physiotherapist - joe bloggs
occupational therapist - jane smith


and the custom properties would be picked up from there and repeated throughout the document (in excel you might set a property to 'B23' for instance)
 

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,779
Office Version
  1. 2010
Platform
  1. Windows
That would require VBA. Or mail merge.
 

merlin777

Well-known Member
Joined
Aug 29, 2009
Messages
1,395
Office Version
  1. 2007

ADVERTISEMENT

That would require VBA. Or mail merge.

I don't think its going to be practical to run a mail merge of just one document at a time?

I'll take a look at VBA although I've only used macros in excel so far so it'll probably be beyond my capabilities at the moment.

Is there such a thing as a pull down list in word like there is in excel?
 

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,779
Office Version
  1. 2010
Platform
  1. Windows
Is there such a thing as a pull down list in word like there is in excel?
Not that I am aware of.

How hard is it to just do find & replace?
 

merlin777

Well-known Member
Joined
Aug 29, 2009
Messages
1,395
Office Version
  1. 2007

ADVERTISEMENT

i'm trying to keep it simple for novice users but that may well be the easiest solution.
Thanks for all your advice.
 

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,779
Office Version
  1. 2010
Platform
  1. Windows
You're welcome.
 

Macropod

Retired Moderator
Joined
Aug 27, 2007
Messages
3,512
You don't require either VBA or a mailmerge for this, and Word does indeed have dropdowns you can use in a document - three different kinds, in fact, plus a combobox.

You could, for example, insert a dropdown content control into the document, formatted with a particular Style. Then, wherever you want the content selected from the dropdown replicated, insert a STYLEREF field referencing that Style. Having made the selection, simply select the entire document via Ctrl-A, then press F9 to update the STYLEREF fields.

Alternatively, or additionally, you could insert a dropdown content control into the document and apply a bookmark to its range. Then, wherever you want the content selected from the dropdown replicated, insert a REF field (e.g. via Insert|Cross Reference) referencing that bookmark. Having made the selection, simply select the entire document via Ctrl-A, then press F9 to update the cross references.

Yet another possibility is to use a dropdown formfield to hold the list, coupled with cross references to its internal bookmark name and 'filling in forms' editing restrictions. If you set the formfield's 'calculate on exit' property, the cross-references will update automatically any time you exit the dropdown.

So many possibilities... and not a hint of VBA or mailmerge.
 
  • Like
Reactions: shg

merlin777

Well-known Member
Joined
Aug 29, 2009
Messages
1,395
Office Version
  1. 2007
You don't require either VBA or a mailmerge for this, and Word does indeed have dropdowns you can use in a document - three different kinds, in fact, plus a combobox.

You could, for example, insert a dropdown content control into the document, formatted with a particular Style. Then, wherever you want the content selected from the dropdown replicated, insert a STYLEREF field referencing that Style. Having made the selection, simply select the entire document via Ctrl-A, then press F9 to update the STYLEREF fields.

Alternatively, or additionally, you could insert a dropdown content control into the document and apply a bookmark to its range. Then, wherever you want the content selected from the dropdown replicated, insert a REF field (e.g. via Insert|Cross Reference) referencing that bookmark. Having made the selection, simply select the entire document via Ctrl-A, then press F9 to update the cross references.

Yet another possibility is to use a dropdown formfield to hold the list, coupled with cross references to its internal bookmark name and 'filling in forms' editing restrictions. If you set the formfield's 'calculate on exit' property, the cross-references will update automatically any time you exit the dropdown.

So many possibilities... and not a hint of VBA or mailmerge.

that's magic, paul. number 2 looks like the boyo for me.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,560
Messages
5,596,842
Members
414,107
Latest member
Tigretto

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top