Word: Fields won’t update

January 18, 2019

I’ve been using Microsoft Word for Windows since about Word 2.0 (yes, more than two decades…) but sometimes it still stops me in my tracks with something I didn’t know existed. And I usually ‘find’ the thing that I didn’t know existed because I’ve come across something in a document that I can’t solve and have to investigate (search Google) to find the cause and the solution.

In a recent document I was editing, I could update the TOC, list of figures/tables, and the fields in the headers/footers using one or more of the usual methods (switch to Print Preview view then back to Print Layout; F9; right-click and select Update Field; update table of contents command etc.).

I’d assumed all the cross-referenced fields in the document had also updated and did my usual check for ‘Error!’ to find anything that broke during the update. On this document I fully expected several of them, but there were none. That in itself was a little unusual especially as I’d redone the Appendix headings, so the original cross-references to them should have broken. But what told me definitively that something wasn’t right was that old template used 3.0, 4.0 etc. for the numbered Heading 1 style, whereas the new template I’d transferred this document to used 3, 4, etc. When I Ctrl+clicked on a 3.0 cross-reference (for example) it went to the correct place. But why wasn’t the cross-reference showing as 3 instead of 3.0?

I thought I’d just try updating one of these cross-referenced fields, but when I selected it and right-clicked, Update Field was grayed out (greyed out). I’d never seen that before, so I tried a few more with the same result—I couldn’t update a cross-reference!

Off to Google… where I found that if the fields are locked (who knew?) then you get a grayed out Update Field option. I had no idea you could even lock fields (or why you’d want to), but I figured I’d try unlocking one of the fields using the method described to see if it worked. It did! Next, I tested (on a COPY of the document, as always) to see if I could select the entire document and apply the fix to ALL fields in the document—that worked too! Immediately all the fields in the document were now updatable.

The fix (test on a copy of your document first):

• Press Ctrl+Shift+F11 on the locked field to unlock it.
• To unlock ALL fields in the document, press Ctrl+A to select everything, then press Ctrl+Shit+F11 to unlock all the fields.

Thanks to Charles Kenyon for having a list of field functions, which is where I found this solution: http://www.addbalance.com/usersguide/fields.htm#Function.

Word: Macro to add left and right padding to all table cells in a document

January 18, 2019

Here’s an issue I found in a document I was editing this week—someone had set most of the tables to have 0 cm padding for the left and right margins of each cell (the default is 0.19 cm for metric users). This meant the text butted right up against the cell borders (it was most noticeable on the left as I was using ragged right justification). I needed to change the cell padding back to 0.19 cm.

This is easy enough to do if you’ve only got one or two tables to fix (select the table, right-click and select Table Properties; on the Table tab, click Options, then set the left and right margins to 0.19 cm; click OK to save and exit).

But this was a nearly 300-page document with hundreds of tables, many of which had their margins set to 0 cm. Off to Google to see if someone had a quicker way. They did. I tested the macro and modified it a bit for my purposes, then ran it on a copy of my big document and fixed the problem on all tables in my document in seconds.

Notes:

• This macro will set the left and right margin padding for ALL tables in your document. In most cases that’s what you’ll want, but if you want some tables to have different padding, change those tables or cells manually after running this macro.
• ALWAYS test on a copy of your document before running the macro on your main document!

Here’s the macro (I suggest you copy it from here so that you get all of it—on some devices, the text may go off the screen):

Sub TablePadding()
'
' Set left and right cell padding for ALL table cells to 0.19 cm
'
Dim oTbl As Word.Table
For Each oTbl In ActiveDocument.Tables
Next



Thanks to Greg Maxey for the original macro that I modified. If you want to change the padding to be smaller or larger, change the 0.19 value to a smaller or larger number.

Featured in the ACES blog

January 8, 2019

I wrote a guest post for the ACES blog, which was published at the end of 2018. It’s a brief summary of my conference presentation on being more efficient with Microsoft Word. You can read it here: https://aceseditors.org/news/2018/making-word-work-for-you

Word: How to fix formatting and case differences in a Word index

December 26, 2018

A reader contacted me asking about his index in Word. It seems some entries were showing as bold, italics, etc. and some, which were the same words but in different case, were showing as separate entries. He wanted all index entries that were the same to be in plain text and listed under the one entry.

Now, it’s an awfully long time since I created an index in Word, but I did remember that you have to create index entries (XE fields in Word) before you can create the index itself (Index field).

I did some testing and found out a few things:

• Entries in different cases are listed separately. Solution: Make them the same case (see below).
• If the first entry for a term has manually applied character formatting (bold/italics etc.), then the formatting in the index takes the manual character formatting of that first entry. If the manual formatting is applied to second or subsequent entries, then it still remains plain text in the index—it’s the formatting of the FIRST entry for that term that’s critical.
• The index only reflects manually applied character formatting, not an applied paragraph or character style (I tested with a Heading paragraph style and the Emphasis character style and each time the entry in the index remained in normal text).

Solution

The solution requires you to see what’s going on, so the first step is to turn on field shading—this will show the hidden text that is the XE fields. Once you can see what’s going on, you can work on fixing it. Just don’t break those XE fields—they are surrounded by curly brackets, the index entry is surrounded by double quote marks, and a colon separates the main entry from the sub entry. These MUST remain intact.

(click an image to see it full size)

1. Make sure your field codes are showing (File > Options > Advanced > Field Shading = Always).
2. Once your fields are visible, you’ll see your index entries as field codes (e.g. {XE “Main entry:Sub entry”}). NOTE: When you make changes DO NOT delete the curly brackets, the colon, or the quote marks. In the example below, you can see the index entries and the resulting mess of an index.

3. Go to the first index entry and check its formatting and case. If bold, italics etc. have been manually applied to it, continue to the next step.
4. Select a field code only (the XE part) and press Ctrl+space to remove any manual character formatting and take the text back to the base paragraph style.
5. If the case is wrong for the main or sub entry elements, manually change it. Don’t add any spaces between the colon and the sub entry.
6. Go to the next entry and check its formatting and case (as for step 3).
7. Repeat steps 4 and/or 5. Do this for several more.
8. Test that it’s working. Go to the index, right click anywhere in it, then select Update Field. Check the entries that you changed in the earlier steps—they should have gone back to normal text and the case should be correct, therefore putting the same entries together. In the screen shots below, the first test showed that the formatting had been sorted out, but the case issues still remained. I went back and fixed the case in the individual entries and then updated the index again—the second screenshot shows the final result.

9. Repeat for the rest of the index entries that have formatting and case issues. Don’t forgot to update the index when you’re finished and check for any that you missed.

Word: Create a custom dictionary populated with thousands of terms

November 30, 2018

There are plenty of websites that tell you how to create a custom dictionary in Microsoft Word. But most assume you only have a few words to add to that dictionary. But what if you have thousands? Doing it one word at a time using the usual methods is painfully slow and not ergonomically sound.

I had such a situation a few months ago, but neglected to write up what I did. I had 4000+ Latin and common species names I’d gathered from public lists that I wanted to add to a unique dictionary so that Word didn’t flag them as spelling errors, except if they really were spelling errors or if they were species I hadn’t included in my species dictionary. I wanted a special dictionary file that I could copy and use on other computers, and turn off if I no longer needed it, so I didn’t want these words added to my default dictionary.

The first thing was to find out where the dictionary files are stored. I use Word for Windows, so this information is for Windows. By default, the Office dictionary files (Office 2010 to 2016, at least) are stored in C:\Users\<username>\AppData\Roaming\Microsoft\UProof and have a *.dic file extension. (Note: Follow these instructions if you can’t see the AppData folder.)

Now, *.dic files are just text files with a different file extension. This means you can open them in a text editor (e.g. Notepad; I use EditPlus because it has a ‘sort’ option, but Notepad works fine). Once you’ve opened a *.dic file in a text editor, you can add, edit, or delete entries. Just make sure you save the file with the *.dic file extension, not *.txt.

Because *.dic files are just text files, you can also use a text editor to create a new dictionary file. However, I started by creating a new (blank) custom dictionary in Word because I wanted to sort them and run a macro to check for duplicates. The main thing to remember is that each word MUST go on its own line. You cannot have two words on one line (that includes compound words with a hyphen). So, in the case of Latin species names, I had to put each part of the name on a separate line — this is why I had to sort the list and look for and delete duplicates (there are more than 700 species of eucalyptus, for example). Once I’d done that I copied them into my text editor, and continued from step 3 below.

In essence:

1. Open a text editor.
2. Add your words, ONE only on each line. Press Enter after each word.
3. Save the file with a DIC file extension (NOT txt).
4. Save it to the UProof folder (C:\Users\<username>\AppData\Roaming\Microsoft\UProof).
5. Open Word and go to Word Options > Proofing. (You need to tell Word there’s a new dictionary to check.)
6. Click Custom Dictionaries.
8. Select your new dictionary file, then click Open.
9. Select the check box for your new dictionary file so that Word knows to check it.
10. Click OK.

That should be it!

Word: My process for copying content into a new template

October 9, 2018

Someone asked me the other day what my ‘best practice’ was for applying a new template to an existing Word document. Well, the answer is: ‘It depends’. And what it depends on is the complexity of the document.

If it’s a simple document in one section, with basic formatting, few—if any—cross-references, uses the same page layout throughout, has little (or no) document automation, etc., then just applying the new template may well be enough (assuming the style names in both are the same). You may have a few tweaks to do with the formatting (e.g. reapplying styles), but you should be done.

However, for a more complex document, like the ones I work on, it’s not so simple. My docs have cover and front matter pages, lots of document automation, outline numbered headings, potentially hundreds of cross-references, many section breaks for landscape and A3 pages, appendices, tables of contents/tables/figures, headers and footers populated with data from the cover page (we used to have odd/even headers/footers too, and various page numbering formats, but we got rid of those some time ago because they just added a lot of overhead for no real value), etc. It’s really the section breaks that will cause you grief, plus totally different cover pages and headers/footers. As for a simple document, the process will be much smoother if the style names in both docs are the same.

Oh, and before you ask, yes, I’ve tried every which way to simplify the process below, but each one just adds more time overhead to sorting out the document after I’ve pulled it over. The method that causes me the least grief is the one below.

NOTES:

• Save often!
• Make sure formatting marks are turned on so you can see the section breaks.
• DO NOT copy section breaks. There lie dragons!!
• You may still have some tweaking to do with applying the correct styles. You can either do this as you go (after each paste), or wait until the end and do it all in a separate pass. Alternatively, make a copy of the old doc, apply the new template to it and fix all the styles first, before copying across the content.

How I deal with putting a complex document onto a new corporate template:

1. Start a new document based on the new template.
2. If you want to preserve any existing comments or track changes from the old doc, make sure track changes is turned OFF in BOTH docs—the new AND the old.
3. Manually complete all the cover page (and other front matter) information in the new doc.
4. DO NOT copy across the old table of contents, list of tables, or list of figures. You’ll update these later (Step 13) with the new headings.
5. Let’s assume the main body of the doc starts at section ‘1. Introduction’. Go to that heading in the new doc, then press Enter a couple of times to create some space.
6. Go to the old doc and copy the content AFTER the ‘1. Introduction’ heading UP TO, BUT NOT INCLUDING, the first section break.
7. Paste that content into the relevant place (the space you just created) in the new doc.
8. Manually insert a section break start AND end for the next section in the new doc, and add some empty paragraphs between them. Change the page layout for the section as necessary (e.g. landscape orientation).
9. Go back to the old doc and copy everything INSIDE the section break, but NOT the section break itself.
10. Paste into the new doc in between the start and end section break marks you created in Step 8.
11. Repeat steps 8 to 10 for ALL section breaks and their content.
12. When you’ve finished, delete any headings and text from the original template that are not required.
13. Go back to the table of contents in the new doc and update it. Repeat for the list of tables and figures too.
14. If you have cross-references in your doc, switch to Print Preview mode, then back to Page Layout mode.
15. Do a Find for ‘Error!’ to find any broken cross-references. Fix, based on the cross-reference information in the old doc.
16. Zoom out to about 30% and do a visual check to make sure your headers/footers for each section are correct for the page layout.

That should be it!

Word: Insert prime and double prime characters

September 23, 2018

Just as there’s a special character for a degree symbol, there are also special characters for prime and double prime symbols (used when referring to latitude and longitude especially). These are NOT the same characters as a single or double quote mark, though many people assume they are.

Use one of these methods to insert a proper prime or double prime symbol in Microsoft Word:

• If you have a separate number pad, then press Alt+8242 (press and hold the Alt key while you type 8242) for prime, or Alt+8243 for double prime.
• Go to the Insert tab > Symbol — the prime symbol is character code = 2032, Unicode (hex), and double prime is 2033.
• If you have Math AutoCorrect turned on, then type \prime<space> for prime, or \pprime<space> for double prime (to turn on Math AutoCorrect: File > Options > Proofing > AutoCorrect Options > Math AutoCorrect tab).
• Supposedly you can also type 2032, Alt+x or 2033, Alt+x but neither of those worked for me.