9

I have a document with a variable being referred to several times on different pages. This is the same variable and so its value is the same on each page. If I need to change this variable I would like to be able change it only in one place and have this change all the other instances of this variable. Similar to when you refactor a variable in code. I can do a find and replace, but the problem is when I have several variables with the same value the find and replace will not differentiate between them, meaning I would need to click through every instance manually and decide if to replace that instance or not.

Is there a way to insert text or mark it in some way so that the document knows that this piece of text is the same as other instances and that changing one changes all others. This is similar to how text in the header and footers work, where changing one header changes all of them, except this would be in the body of the document.

11

A standard way to handle repeated text is to use bookmarks in conjunction with REF fields. Each bit of repeated text is stored in a bookmark, and each repetition of that text is inserted via a REF field that is linked to the bookmark. So it doesn't matter if two bookmarks happen to store identical looking text at a given time.

  1. Select the text that needs to be repeated, and insert a bookmark (on the Insert tab, in the Links group, click Bookmark).
  2. At each place where you need the text repeated, insert a REF field (on the Insert tab, in the Text group, click Quick Parts > Field, select Ref, and then select the name of the bookmark in the list).
  3. After you change the bookmarked text, select the whole document, and then press F9 to update the REF fields.

As came up in another recent question, it helps if you make bookmarks visible if they aren't (click File > Options > Advanced, and then, under Show document content, select Show bookmarks). Otherwise, when you change the text, some of the new text might end up outside the bookmark, and your changes won't be propagated. When the bookmarks are visible, you can see whether all the new text is correctly inside the bookmark.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.