What tool to auto-populate fields in MS Word?

Hopefully someone can help!

For reasons, still need to use MS Word (Word for Mac v16).

A few times a year, I have occasion to send out letters (saved as PDF to email as attachments) confirming that Person X did A/B/C.

The letters are in a formal style.
So, at the outset, it identifies Person X, and then refers to them by their full title all the way through the letter again.

I want to insert “fields” for each time Person X is mentioned in the letter.
The idea being that I enter Person X once, and this then automatically updates all the other instances.
(Or, when I change the first instance to Person Y, then all the later instances will change to reflect Person Y accordingly.)

Somewhere in the past, I could get this to work. Now, I’m struggling.

I don’t know what to search for. This doesn’t appear to be Autotext. Or a Bookmark. And “fields” seem to be limited to a series of existing ones, inside of Word.
It might be something required from inside the Developer tab (which I have activated)?
Regardless, I have been googling without success, probably because I am looking for the wrong thing.

Anyone who can point me in the right direction?

This seems like something that should be easy — but silly how much time I have (unsuccessfully) spent on this already!

I’m hoping someone can give you the answer you’re looking for, because it should be doable.

In the meantime, my workaround is Find/Replace, which only takes me a few keystrokes. My document has xfullnamerecipientx everywhere the name is needed. I Find that, put Wyatt Haygood Stephens IV in the Replace box, and click Replace All.

I know that’s more work that you’re wanting for the long-term solution but it can hopefully save some time in the interim?

Thanks – that would work – but it’s a bit more than simply a {surname}.
[Should’ve made that clear above!]

It would involve {Title} {FirstN} {LastN}, and then also see occasional changes to {MonthOfA/B/C} and {YearOfA/B/C} – so the Find/Replace (which could also be done via KM, most likely), becomes a bit more tedious/onerous.

Going to pop something up in the MS forums as well – I occasionally get lucky with assistance there.

Is that information in another file? That’s what the [field] function of word is for (think mail merge) but I was assuming you didn’t have the information neatly organized in another file. Perhaps my assumption was wrong?

1 Like

Nope. It isn’t really – it’s not a major list, just enough to make me want to automate this – but the persons involved are ad-hoc, and change from year to year.

Also – this would apply to quite a few different contexts, so trying to figure this out again – since could be useful down the road.

Gotcha. That is tricky. I’ve had this bookmarked for my own future use, but I don’t think it works if you don’t put the data in another file first so that Word has somewhere to pull from.

2 options

  1. is this not just a simple Mailmerge using Excel and Word?
  2. use a Textexpander snippet with fill ins for the whole letter with text boxes which can be completed the first time and will put the same info each of the text boxes with the same title E.g. ForeName.
3 Likes

Many thanks!

Re #1:
The way I understand Mailmerge – this would be ideal where I am sending out a high volume letter, and want to have a single(?) component pulled in from Excel, typically in the salutation (i.e. Dear [mailmerge info]…)?

Re #2:
Yes, TE could do this. Would probably need a bit of tweaking after the fact, to get formatting set – but probably doable.

Was just hoping for a “native” solution inside Word.
I didn’t think what I was asking would be so unusual – but as mentioned, I have been digging around, and somewhat surprisingly, not getting much in terms of answers… So TE might very well be what I settle on.

Mailmerge can take many fields from an Excel document or a database and add them to a word file. I’ve seen mail merges with 15-20 pieces of data inserted.

2 Likes

Did not know that – looks like I have some homework to do.

Thanks for the links – this might be easier than the some of the suggestions I have seen so far (involving VBA macros, and options seemingly only available on the Windows’ versions).

Sounds like you are looking for XML Mapping, which I use every day. I have various templates which are full of Content Controls (added from the Developer tab). Then I have XML data which is mapped to those controls. If I change the data in one Content Control, it is updated in all Content Controls throughout the document which are mapped to the same underlying XML data.

Unfortunately, Word does not provide a very usable interface for working with the XML data. There is the XML Mapping pain (available from the Developer Tab), but you can’t edit the XML there. All you can do is map the data to Content Controls. However, you can “add new part” which accepts an XML file. I have used my text editor to manually create an XML file with the data structure I want, then imported it from the XML Mapping pain and mapped each node to the various Content Controls (see this YouTube video for example). Although, there are a few third party extensions/add-ins to Word which provide more control from Word (I use this one; you will also find a lot of info in that site about content controls and XML mapping; I suggest you start here).

Automating populating the data is a little more tricky as mail merge doesn’t work with Content Controls (I think). I’m using this on Windows (as required by my employer) and am comfortable with Python, therefore I am using the Python win32com library to access Word’s APIs (basically a one-to-one mapping from Word’s VBA APIs to Python; see this YouTube video for how to access the XML part from VBA). From my scripts I can open a new document from a template and step through the XML and populate each node with my data. Then the Content Controls in the document are all properly filled in. I’m not sure if Word’s Applescript support on Mac supports this or not.

1 Like

Sounds like a job for MailMerge as @geoffaire has suggested.

But! if the volume of documents to prepare is small (as in less than 10 or something like that) I think I would prefer using good old find & replace. Maybe you could throw son keyboard macros (Keyboard Maestro or Better Touch Tool) to invoke the Find & Replace dialog and pre-populate the search term so you only have to enter the real text for each of the “fields”.

2 Likes

Has Mail Merge fallen out of favor? I remember struggling through my first mail merge project, working as a personal computer trainer, on an Apple II back in 1982 using DB Master, the Data Base Manager, V3, Stoneware Software, 1982. Apple II | eBay. I forget the word processor used but it had to be Wordstar or maybe XyWrite, which was an early favorite of mine. :slightly_smiling_face:

Everyone keeps suggesting MailMerge, but it won’t do that. When you run Mail Merge, it matches up the named bookmarks in the document with the data columns in your source data. However, it replaces those bookmarks with plain text in the document. The generated document no longer has any knowledge of the bookmarks. Therefore, you can’t later change the data in one location and have it propagate to all other locations in the document.

To get that feature, you need Content Controls with XML Mapping. However, if you have no intention of ever editing the documents after creation, yes, mail merge is the easier feature to set up and use.

1 Like

For the record, I suggested “Fields,” not mail merge. And I provided a link but the issue was that the data doesn’t live in an external file in the first place.

No, but you can change the data and re-run the mail merge.

1 Like

The piece you are missing is custom document properties. You can add custom document properties to any file to hold the information you mention. For example, you can make a property called “Person” to store the name. You can make a property called “Action” that could store either A, B, or C. Then you use the DocProperty field to recall that information as many places as you want in the document. Look below to see how to use the fields.

{DOCPROPERTY “Person”} did {DOCPROPERTY “Action”}

For the record, I did mail merging with Wordstar on an IBM PC clone while at highschool circa 1988.

1 Like

Macsparky’s Keyboard Maestro guide has a chapter on setting up a template in Word with a table or index in Keyboard Maestro which allows you to enter the data for individual “letters” from the form.

I have to confess I have not been able to get it to work but he does demonstrate it working well. So, if you have that field guide, it would be worth a try in case you have better luck than I did.

2 Likes