Archive for the ‘Word’ Category

h1

Word: Format all cross-references as bold

June 17, 2022

One of my clients does work for a [big company], and I do the occasional bit of work for them. The [big company] wants the all cross-references (x-refs) in bold type (e.g. Table 1-4, Figure 2-10, Appendix F, Section 10.8 etc.). But there’s no way that I’ve found in Word to set this as an automatic attribute when creating x-refs (if anyone knows how, let me know in the comments). So bold has to be applied manually, and for a 400p document with hundreds of x-refs, that’s tedious for the authors and for me as the editor when some have been missed.

However, there is a way to bold ALL the x-refs at any time (ideally as one of the finalisation stages when working on a document). And it’s a simple find and replace solution (no wildcards involved!), but you do have to expose the field codes for it to work.

How to do this:

  1. Make a new copy of your document using Save As (this is just in case anything goes drastically wrong—it shouldn’t, but you never know).
  2. Select the entire document using Ctrl+a.
  3. Press Alt+F9 to toggle (and display) the field codes.
  4. Press Ctrl+h to open the Find and Replace window.
  5. In the Find field type: ^19 REF (^19 represents a field and the REF tells Word to look for a field that also has REF as part of its code—this gets all the x-refs but ignores things like the table of contents and other field codes).
  6. Click More.
  7. Put your cursor in the Replace field but DO NOT TYPE anything here.
  8. Click Format.
  9. Select Font.
  10. Select Bold in the middle panel at the top of the Font dialog box.
  11. If your cursor was in the Replace field, then immediately below that field Font: Bold displays. (If your cursor was still in the Find field, then Font: Bold will display under that, and that’s not what you want—go back and repeat from step 7.)
  12. Click Replace All.
  13. When the replace has finished, close the Find and Replace window
  14. Press Alt+F9 to toggle the field codes back to readable x-ref numbers etc.
  15. You may need to update the fields after doing this, just to make sure the bold is applied to them all. To do this, go to File > Print (which puts you in Print Preview mode), DO NOT PRINT, then go back to your document—this updates all your fields. Check your table of contents etc. If all the page numbers are the same, update the table of contents etc. separately as you normally would.
  16. If you’re happy with the changes made, continue using the ‘saved as’ document as your current version, or repeat these steps in the earlier current version you saved from (your versioning processes may differ).

I got my inspiration for this post from this very long webpage, written by Susan Barnhill, one of the Word gurus: http://wordfaqs.ssbarnhill.com/FormatCrossReferences.htm

h1

Word to PDF: Table of Contents not clickable

May 6, 2022

One of my clients had a situation where the table of contents (TOC) in their Word document did not become a clickable (linked) TOC in the PDF they created from it. By default, it should. because the standard settings for clickable links in a PDF are to include the usual Heading styles from Word. They had used standard Heading styles, so there was no reason why they shouldn’t be linked. Other elements such as cross-references to sections, appendices, tables, and figures all worked fine in the PDF, but not the TOC entries.

I checked their TOC settings and there I found the reason and the solution. NOTE: You can’t open these TOC settings if you’ve inserted a default (Microsoft-supplied) TOC from the References tab—you must have inserted a custom TOC.

  1. Open the Table of Contents window (References tab > Table of Contents > Custom Table of Contents).
  2. Make sure the Use hyperlinks… checkbox is selected. This checkbox is selected by default, so if it’s been turned off at some point, turn it on.
  3. Click OK.

Now, create your PDF—the TOC in the PDF should now be clickable.

Update June 2022: For a full discussion of the different PDF outputs when you Save as or Print to PDF from Word, see this excellent article: https://office-watch.com/2022/choices-make-a-pdf-file-save-or-print/

h1

SharePoint: Won’t open a Word document in Office 365

March 15, 2022

I need to state upfront that I HATE SharePoint (SP) with the passion of a thousand burning suns!

Now that I’ve got that out of the way, I’m hoping someone reading this can help me find a solution as to why I can’t open a Word document in SP using my installed Office 365 version of Word (NOT Word Online, which I hate almost as much as SP!)

A bit of background…

  • My client sent me a link to a document stored on their SP server. I couldn’t access it and let them know.
  • They added me as a legitimate user, using my standard email address (firstname.lastname@domain.com.au), and I got a welcome message from their SP server, with a link to the area containing the documents I needed to access.
  • I have several Microsoft (MS) accounts as I work for different clients who need me to access their SP servers, AND I’m a member of the Microsoft Partner Network for the Action Pack Subscription. I tried the first two I have and the one that uses my email address (as above) got me in. (NOTE: Microsoft seems to think that everyone only has ONE ID and only works for ONE employer/client—freelancers are really in a bind with the multiple credentials they may have to access anything from MS via the internet)
  • I could see the client’s folders and documents (yay!).
  • I opened the Word document they wanted me to look at but Word Online has limited functionality and I needed to get in deep, so I found the option for opening in the desktop app. I wanted to do that in preference to downloading the document as it would remain in SP, whereas with downloading it, I’d have to either upload it again (and I likely didn’t have permission for that), OR I’d have to email it to my client or put it in Dropbox if it was too big to email and then they had to upload it to replace the original. Clunky.

It’s at the desktop app step that I ran into a big issue that I can’t resolve. What happened? Well, when I said to open in the desktop app, SP ONLY offered the option of opening the doc in Office 2010, which I still have on my PC but which I never use (I held onto it when I went to Office 365, just in case I needed to go back to it). There was no option to open it in Office 365, which is what I use. My only other option was to cancel, which is what I did.

I let my client know, and headed off to Google to see if others have had similar issues. I found all sorts of horror stories about uninstalling Office 2010 well after Office 365 was installed, other info about repairing Office 365, and almost nothing on the interaction between SP and an old version of Office when a new one is installed. I may well have been clutching at straws with my search terms… However, I did find one website that offered a possible reason (#6 in their list): https://windowsreport.com/sharepoint-wont-open-excel-word/

And that possible reason was to do with the account you’re signed in with. I mentioned earlier that my email address (and one of my MS accounts) is firstname.lastname@domain.com.au, but my Office 365 account ID is firstname@domain.com.au. (i.e. no lastname). I then asked my client to add me with that email address, which he did, hoping that would be the answer. But then he got error messages from SP on his end. And the link he sent me didn’t work either (different error messages to those I got initially—something about my address not being valid!). So he’s given up too.

I can still go old school and download the documents to my local machine and email them back.

I also still think it’s related to the account I’m signed in with in Office, but I don’t want to try anything else in case I break it and can’t get back to where I was. Has anyone come across this and solved it? If so, please share your solution in the comments below.

Thanks!

[Link last checked March 2022]

h1

Word: DocProperty field won’t update

March 15, 2022

My client’s doc had a DocProperty field in the footer for ‘Subject’, but no matter what I did with the content controls or the field code, it wouldn’t update to reflect the text in the ‘Subject’ Content Control on the title page.

But what I *did* notice when I was in the Edit Field window for that field was that there were TWO instances of ‘Subject’. Neither worked. So my next strategy was to delete one or both of them and start again. However, deleting a Document Property is fairly well hidden in later versions of Word, and I couldn’t find it easily—it certainly wasn’t where I expected it to be in the Developer tab: it’s only accessible via File > Info > Properties > Advanced Properties.

Access the document propeorties window by going to File > Info > Properties > Advanced Properties

Document Properties window with the Custom tab selected

Once I was on that screen, I saw that there’s an in-built property for ‘Subject’ on the Summary tab, and I found the other one on the Custom tab. I selected the one on the Custom tab, deleted it, then clicked OK. The DocProperty field in the footer then updated correctly to reflect the text in the Content Control.

NOTE: You can only select and delete custom properties that have had a value added for them and that have been added to the document.

h1

Word: Custom heading styles cannot be used for caption numbering

March 7, 2022

Here are some things I found out last week when a client called and asked for help with table and figure captioning:

  • You can ONLY use chapter/section numbering in a table/figure etc. caption IF you use Word’s Heading 1 to Heading 9 styles for your headings (and they are set for outline numbering), as these are the ONLY options available to you on the Caption Numbering window of the Caption window
  • If you’ve created your own outline numbered heading style and called it MyCompany Heading 1, you cannot select that style for auto numbering the captions. (A little more info: https://social.technet.microsoft.com/Forums/office/en-US/391594c0-a20c-4676-9592-b8f825b1ce57/change-a-custom-heading-style-in-such-a-way-that-the-caption-tool-recognises-the-heading-so-the?forum=word)
  • If you try to rename the in-built Heading 1 style to MyCompany Heading 1, then when you click OK, Word will change the style name to Heading 1,MyCompany Heading 1 (i.e. it will append your name to the Heading 1 style name)
  • If you right click immediately before the chapter numbering field in a caption and select Toggle Field, you’ll see { STYLEREF 1 \s }, where StyleRef is the field code, ‘1’ represents the heading number (1 = Heading 1), and \s is an undocumented switch code that I think means to reset the sequence after each Heading 1 (based on some information I found here for SEQ field codes: http://www.addbalance.com/usersguide/fields.htm).

So, what can you do? Well, you have a few options…

Option 1: Use Word’s Heading 1 style

The simplest option is to use Word’s Heading 1 style for your top-level headings. Style it according to what you want (font and paragraph settings, numbering, tabs etc., even add your own name to the style name), but don’t set up your own style for heading 1s if you also want to use auto numbered captions. There are other reasons to use Word’s own heading styles too—see this article for 16 reasons why: https://shaunakelly.com/word/numbering/usebuiltinheadingstyles.html

Option 2: Modify the StyleRef field code

Update a week later: This option may NOT work successfully. When I tried it, I’d get one or two right, then I’d do another in a new heading and the first ones wouldn’t work, or I’d get a continuous sequence number for the second part of the caption number. 

This option is feasible if you use your own heading 1 style and only have a few captions. If you have many, it will become very tedious and hard for others to manage if they don’t know what you did. In this method, you’ll change the ‘1’ in the field code to the name of your own heading 1 style (I’ve used MyCompany Heading 1 as the example; your style name will be different):

  1. Right-click immediately before the chapter numbering field in a caption and select Toggle Field Codes. You should see { STYLEREF 1 \s }. If you don’t, then position your cursor immediately in front of the chapter number part of the caption number (the first number) and try again.
  2. Right-click in the field (anywhere inside the { } ), then select Edit Field.
  3. Select your own heading 1 style from the list, then click OK.
  4. The caption number should now reflect your custom heading 1 chapter/section number. If it says Error! No text of specified style in document. then either you don’t have any outline numbers for your custom heading 1 style or you haven’t used that style in your document.
  5. If you right-click on the field again, you should see { STYLEREF “MyCompany Heading 1” \s }, where MyCompany Heading 1 is the name of your custom heading 1 style.
  6. Repeat these steps for EVERY table/figure or other caption you have that uses chapter/section numbering as part of the caption.

Tip: Get one right, then copy/paste it to replace other captions, then update all the fields. I haven’t tried this, but it should work. Test on a couple first, not the several hundred you have—if it works on those, then repeat for the others you have.

Option 3: Use an add-in

In my searching for an answer to this issue, I found a free add-in that’s available from one of the very helpful people on the Word VBA forums: http://jay-freedman.info/custom_style_captions.htm

Notes:

  • I have NOT installed or used this add-in so I can’t comment on its usefulness or not; however, the author of it is someone I trust who knows their stuff.
  • The webpage for this add-in says that it works (has been tested) up to Word 2016. There’s a very good chance that it works with later versions of Word too, but as I haven’t tested it I can’t confirm that.
  • I suspect that this add-in might only work on Word for Windows—I don’t have Word for Mac so I can’t test it on that.

[Links last checked March 2022]

h1

Word: Find all upper case words within parentheses and change to lower case

March 6, 2022

One of my readers asked if there was a way to change upper case strings within parentheses to lower case. For example, (INHALED DEEPLY) to (inhaled deeply). It seems they had hundreds of them, so doing them one at a time wasn’t the most efficient use of their time.

I was able to come up with a wildcard find to identify them all, but I couldn’t come up with a replace that preserved the contents while changing the case. I fiddled around a bit trying to get a macro to work, but to no avail. Then I decided to ask my question on the Microsoft support forums, but before I did so, I did a quick search to see if an answer had already been given—and it had! (https://answers.microsoft.com/en-us/msoffice/forum/all/search-and-replace-uppercase-to-lowercase/b2ed6ffa-4fe7-450d-a66c-7578811ce71f)

NOTE: As always, test on a copy of your document before you run this—you are making a global change that may target more than you want. For example, these will all get changed to lower case:

  • upper case acronyms in parentheses
  • anything inside parentheses that starts with a capital letter, such as proper nouns, whether in all upper case or not
  • everything from the first upper case letter after an opening parenthesis to the first-found closing parenthesis, which might be some pages later if you forgot to close the parenthesis.

This is a brute force method and may have unintended consequences. If in doubt, click Find Next to check each instance before you make this global change. 

Steps to achieve this:

  1. Press Ctrl+h to open the Find and Replace window.
  2. Click the Find tab (this is important).
  3. In the Find What field, type \(([A-Z]*)\)
  4. Click More and select the Use wildcards checkbox.
  5. Click Find In and select Main Document from the drop-down list.
  6. All matches are found and automatically selected. DO NOT click inside the document otherwise you will lose the selections.
  7. Go to the Home tab and click the Aa icon in the Font group and change the case to lower case. This will change the case of everything selected.

[Link last checked March 2022]

h1

Word: Deleting many unused styles at once

February 23, 2022

Today I went down the rabbit hole of how to delete hundreds of unused styles in a document. Deleting them manually, even using the Organizer (see my blog post on this: https://cybertext.wordpress.com/2010/01/28/word-remove-unwanted-styles-quickly/), is tedious, so I wanted to find if there was an easier way using a macro or similar.

Bottom line: It may be easier to use a macro or one of the other methods (1 to 4) described below if you have a fairly short and not terribly complex document. BUT if you have a large complex document (e.g. with control boxes for document properties, outline numbering, modified settings for inbuilt styles such as heading and TOC styles), you could be making more work for yourself than doing it manually, consider using the macro in Method 5 (added after this post was originally written). 

Test environment: I used a copy of a client’s 440p document, which had appendices, outline numbering, portrait/landscape sections, headers and footers, control boxes for doc properties that were repeated in the headers/footers, automated cross-references, automated caption numbering etc. It also had hundreds of styles, many of which seemed to be unused, that seemed to have come in from other documents or had been created for a specific need—it was these I was trying to get rid of quickly. I printed the list of styles to PDF—this document was 129p long!

My Google searching led me to a couple of sites and forums that seemed to address this issue, a couple of which used macros to achieve the task. One used a version of ‘maggying’ a document (named for the late Maggie Secara, after whom the technique is named), so I tried that first—why use brute force if something simple can achieve what you want?

Method 1: Maggie the document and put it into a new blank document

I found this method here: https://darrengoossens.wordpress.com/2019/04/11/removing-unused-styles-from-a-word-document/. It seemed an ideal solution—quick and simple, with the outcome I wanted. However, it just didn’t work for me. After 45 minutes waiting for the copied text in the 440p document to paste, with ‘not responding’ in the title bar of Word, I finally killed the process. However, I haven’t written off this method as it could be a good solution for smaller documents with many styles. (See Method 4 for some issues I found using this method on a complex document.)

Method 2: Allen Wyatt’s macro

The next thing I tried was a macro from Allen Wyatt, the WordTips guy: https://word.tips.net/T001337_Removing_Unused_Styles.html. From another forum I was aware that the header/footer styles might get removed using his macro, so I was ready to check that. However, I got ‘not responding’ in Word again, and after 40 mins waiting for something to happen, I killed the process again. This may be a solution for a smaller document, but didn’t work for me—I expect a macro to take a few minutes at most.

Method 3: Paul Edstein’s macro

The next macro was one from Paul Edstein (a variation of Allen Wyatt’s DeleteUnusedStyles macro) that I found here: https://www.msofficeforums.com/word-vba/37489-macro-deletes-unused-styles.html. Supposedly, this one didn’t remove header and footer styles, which are always listed as unused even when they are (yes, that’s Word being Word…). This one took about 25 mins to run on my 440p document, and the list of styles seemed to reduce. However, when I checked them, many of the unused styles were still listed and hadn’t been deleted at all. These styles were user-added (not inbuilt styles) and as far as I know, were not linked to other styles, though it’s difficult to tell what’s linked to what.

Method 4: Method 3 + Method 1

As a final test, I took the copy of the document I’d saved from Method 3 and ran Method 1 on it; that is, I ran Paul Edstein’s macro, then used the Maggie method to put the document into a new blank document.

This time the copied text (all 440p) pasted quickly (within a minute) and Word didn’t hang. However, all the unused styles still remaining after running the Method 3 macro were copied across, even though all indications are that they AREN’T used. But the resulting document had further issues that would have to be fixed manually. For example:

  • I lost the content in the doc control boxes for the doc #, doc title etc. in the headers/footers and main body of the document—the control boxes were still there, but the content was gone. These were easy enough to add back in by copy/pasting from the original document, but be aware that this content, if you use it, may disappear.
  • All style formatting for built-in styles such as Caption, TOC 1, TOC 2 etc. and Table of Figure styles was lost. I could easily import them back in using the Organizer. Heading 1, 2, 3 etc. had lost the outline numbering and instead had reverted to a different numbering schema, different fonts, different colours, etc. Again, I used the Organizer to reestablish these.

With these results, I didn’t bother checking any further.

Was this combined method worth it? No, because of the time taken in identifying and then fixing up the issues with the styles.

******

As a final note, when I printed the styles used in the doc (to PDF, NOT paper), the untouched original had 129p of style definitions listed. I fully expected this to be less after deleting all the unused styles using the methods listed here, but instead the PDF of the styles in the modified document (Method 4) ran to 143p!!! This PDF included the styles I’d manually deleted after checking there were unused. This matches the information I discovered as I was researching this, and that’s that the ‘in use’ styles are ANY styles ever used in the document, whether they are still in use or have been deleted.

There has to be an easier way that actually deletes all the unused styles and that doesn’t create even more work or take time that could be used manually deleting them. And Microsoft needs to look at why ‘in use’ styles include ANY styles EVER used in the document, even after they’ve been deleted—‘in use’ to me means ‘being used right now’, not was used 5 years ago on an older template.

Update 25 Feb 2022: One of the commentators on this post shared another macro, which, after some tweaking (because WordPress changes things like plain quote to smart quotes, hyphens/dashes, underscores and totally removes angle brackets, etc.), I got to work on my long document. I’ve added it as Method 5.

Method 5: Simon Jones’ macro

This macro has two parts—first it identifies how many styles are in-built and how many are custom (user-added). Once it’s done that, you are asked to click Yes or No to continue to delete the unused custom styles. In my test document, this part of the macro identified almost 900 (!!!!) custom styles.

Message box telling me that there were 897 custom styles used in the document, and 374 in-built styles

After the macro had run (and it took about 30 minutes to run on the 440p document—an acceptable time, in my opinion), I was left with 38 custom styles that were used in the document. A much more manageable list!

Message after the first part of the macro ran saying there were 38 custom styles remaining in the document

Notes about this macro:

  • If you’re using a version of Word prior to Word 2007, you will have to comment out the lines that have ### in them.
  • Copy/paste this macro—some of it goes off the visible window

 

Sub DeleteUnusedStyles()
 
'Simon Jones, MillStream Designs Ltd, 05/03/2007
'macro originally called DeleteUnusedStylesTake3

Dim objStyle As Word.Style
Dim intBuiltInStyles As Integer
Dim intStyle As Integer
 
'Count the number of built-in styles in this document
 
For Each objStyle In ActiveDocument.Styles
    
    If objStyle.BuiltIn Then
        intBuiltInStyles = intBuiltInStyles + 1
    End If
    
Next objStyle
 
'Show summary and ask permission to continue
 
If MsgBox("There are " & intBuiltInStyles & " built-in styles " & vbCrLf & _
          "and " & ActiveDocument.Styles.Count - intBuiltInStyles & _
          " custom style(s) in this document." & vbCrLf & vbCrLf & _
          "Delete unused custom styles?", vbOKCancel + vbExclamation, _
          "Delete Unused Styles") = vbOK Then
          
    'OK to continue
    'Run through all the styles in the document BACKWARDS -
    'so we only delete styles from the end of the collection
    
    For intStyle = ActiveDocument.Styles.Count To 1 Step -1
        
        If Not ActiveDocument.Styles(intStyle).BuiltIn Then
            'This is a custom style
            'See if it is in use
            
            With ActiveDocument.Content.Find
                .ClearFormatting
                .Style = intStyle
                .Execute Format:=True
                
                If Not .Found Then
                    'Style is not in use
                    'We can delete it
                    
                    With ActiveDocument.Styles(intStyle)
                        'If this style is linked to another we have to unlink them -
                        'otherwise both styles will be deleted which causes problems -
                        'this style may be linked to a built-in style which will cause -
                        'an error if we try to delete it.
                        
                        If .Type <> wdStyleTypeCharacter Then
                            'Character styles can't be linked from, only linked to
                            
                            'The Linked property only exists in Word 2007 and above -
                            'for previous versions, comment out the "If" and "End If" lines below
                            
                            If .Linked Then   '### Word 2007+ only
                                'The LinkStyle property only exists in Word 2002 and above -
                                'for previous versions, comment out the lines below
                                
                                If Not .LinkStyle Is ActiveDocument.Styles(wdStyleNormal) Then '### Word 2002+ only
                                   .LinkStyle = wdStyleNormal '### Word 2002+ only
                                End If       '### Word 2002+ only
                                
                                'LinkStyle is a very badly behaved property and this is the -
                                'closest we can get to unlinking styles short of copying all -
                                'text except the last paragraph mark to a new document.
                            End If           '### Word 2007+ only
                            
                        End If
'
                        'Ignore any error caused by trying to delete
                        'a style whose name begins with a space
                        On Error Resume Next
                        .Delete
                        On Error GoTo 0
                    End With
                
                End If
                
            End With
            
        End If
    
    Next intStyle
    
    'Display summary
    MsgBox "There are " & ActiveDocument.Styles.Count - intBuiltInStyles & _
           " custom style(s) left in this document.", vbInformation, "Unused Styles Deleted"
End If
 
End Sub

 

[Links last checked February 2022]

 

 

h1

Word: Italicise numbers inside parentheses

December 2, 2021

In a comment on another blog post, one of my readers asked if there was an easy way to find all numbers and change them to italic. Well, there is (Option 1 below), but there was a further complication—some of these numbers were a range separated by a dash, and some were separated by commas. For example:

  • (123456)
  • (1-4)
  • (1, 5)
  • (1, 5, 12)

I couldn’t find an easy way to do this all at once, but you can do it by running several wildcard find and replace routines. If someone else has an easier or more elegant solution, please add it in the comments.

NOTES:

  • Tip: Just in case anything goes wrong, make a copy of your document before you start and do this in the copy until you are satisfied it works as you expect.
  • Tip: Only click Replace all once you are confident that it works.
  • Numbers are whole positive integers—no decimals, no ordinals, no negative numbers.
  • ‘Dash’ is the standard hyphen character on the keyboard, NOT an en or em dash, or a minus symbol.
  • All find and replace routines are done with Use wildcards turned on (Ctrl+h, click More, select Use wildcards).
  • Tip: Copy the find strings from here and paste into your Word find field.

Option 1: Find all numbers and change to italics

  1. Find: ([0-9])
  2. Replace: \1
  3. When in the Replace field, click Format > Font, and choose Italic.

Note: EVERY number in the document will be italicised.

Option 2: Find whole numbers only inside parentheses and change to italics

For example: (123456), (789), (23)

  1. Find: \(([0-9]@)\)
  2. Replace: ^&
  3. When in the Replace field, click Format > Font, and choose Italic.

Note: The numbers AND their surrounding parentheses will be italicised. See Option 6 for how to change the parentheses back to normal text.

Option 3: Find whole numbers separated with a single dash inside parentheses and change to italics

For example: (12-3456), (7-89), (2-3) [there are NO spaces before or after the dash]

  1. Find: \(([0-9]{1,9})(-)([0-9]{1,9})\)
  2. Replace: ^&
  3. When in the Replace field, click Format > Font, and choose Italic.

Note: The number ranges, the dashes, AND their surrounding parentheses will be italicised. See Option 6 for how to change the dash and the parentheses back to normal text.

Option 4: Find 2 numbers separated by a comma and a space, inside parentheses, and change to italics

For example: (1, 2), (25, 67)

  1. Find: \([0-9]{1,9}, [0-9]{1,9}\)
  2. Replace: ^&
  3. When in the Replace field, click Format > Font, and choose Italic.

Note: The numbers, the comma, the space, AND their surrounding parentheses will be italicised. See Option 6 for how to change the comma, space, and the parentheses back to normal text.

Option 5: Find 3 numbers separated by commas and spaces, inside parentheses, and change to italics

For example: (1, 2, 3), (25, 67, 345)

  1. Find: \(([0-9]{1,9}, [0-9]{1,9}, [0-9]{1,9})\)
  2. Replace: ^&
  3. When in the Replace field, click Format > Font, and choose Italic.

Note: The numbers, comma, spaces, AND their surrounding parentheses will be italicised. See Option 6 for how to change the commas, spaces, and the parentheses back to normal text.

Option 6: Change all commas, spaces, dashes, and parentheses back to normal text

  1. Find: ([, \(\)-]) (Note: there’s a space after the comma in this string)
  2. When in the Find field, click Format > Font, and choose Italic.
  3. Replace: ^&
  4. When in the Replace field, click Format > Font, and choose Not Italic.

 

h1

Word: Apply a keyboard shortcut to a style

November 5, 2021

I realised I hadn’t written up one of the tricks I use every day! And that’s to use the keyboard to quickly apply a style to a piece of text. I’ve set up different keyboard shortcuts for the styles I use most (e.g. Body Text, Table Bullet).

Update: Some common styles already have inbuilt keyboard shortcuts:

  • Heading 1: Ctrl+Alt+1
  • Heading 2: Ctrl+Alt+2
  • Heading 3: Ctrl+Alt+3
  • List Bullet: Ctrl+Shift+L

Here’s how to add keyboard shortcuts for other styles:

  1. Go to File > Options > Customize Ribbon.
  2. Click Customize (the button next to Keyboard Shortcuts, below the left panel).
  3. Scroll to the end of the Categories section.
  4. Click Styles, which is the second-last category. The right section changes to list all the style names in the template.
  5. Click on a style name (e.g. Body Text).
  6. Check the Current Keys box to see if there’s already a keyboard shortcut assigned to it. If not, go to the Press new shortcut key field and PRESS the keyboard combination you want to use (DO NOT type the keys—you must press them as though you were using the keyboard to do the action). If a keyboard shortcut is already assigned to the selected style, you can cancel out of these screens and use it, or change it by continuing with the steps below.
  7. Check for any message below the Current Keys box to see if this key combination is used for something else in Word. If so, press another combination. Once you see [unassigned] listed, you know you can use that keyboard shortcut.
  8. Click Assign to assign your keyboard shortcut to this style.
  9. Repeat Steps 5 to 8 for any other styles you want to assign keyboard shortcuts to.
  10. When you’ve finished, click Close, and then OK to exit the windows.
  11. Test that it works by adding some plain text then pressing your keyboard shortcut—the plain text should now be styled with the style assigned to that keyboard shortcut.

Bonus: If you have a lot of documents that use different templates, provided a document has the same named styles as you’ve set for your style keyboard shortcuts (e.g. Body Text is used across documents—even though it might be styled differently in each document), the keyboard shortcut will work across all of those documents and apply the correct Body Text style from each template.

 

h1

Word: Replace HTML em markers with italics

November 1, 2021

In a comment on another post, J had this problem: the text file that they’d copied into Word had the HTML code markers for emphasis (em enclosed by the greater than < and less than > arrows)and they wanted to get rid of these markers and change the text between those markers into italics. Unfortunately, WordPress won’t allow me write that code as it wants to automatically convert it into italics!

I solved their problem by using a wildcard find and replace in Word. Here’s how:

  1. Press Ctrl+h to open the Find and Replace window.
  2. Click More.
  3. Select the Use wildcards checkbox.
  4. In the Find field, type this (copy it if you think you’ll get it wrong; there are NO spaces in this string): (\<em\>)(*)(\</em\>) 
  5. In the Replace field, type this: \2
  6. While still in the Replace field, click Format (bottom left of the find/replace window), then Font, then select Italic. Font: Italic should display below the Replace field, as shown in the screenshot.
  7. Click Find Next. if you’re happy with what it found, click Replace. Only click Replace All if you’re confident that every instance of em has a closing em marker nearby.

How this works:

  • Each element of the Find is enclosed by parentheses. There are three elements — the opening em marker (#1), the text in between (#2), and the closing em marker (#3)
  • Because the greater than and less than symbols have special functions in Word’s wildcard find/replace, you have to ‘escape’ them by putting a \ in front of each
  • Because we don’t know which word or words or phrases or numbers are between the em markers, we use * to represent anything between an opening and a closing em marker
  • In the Replace, we don’t need the em markers anymore, so we omit them from the replace. But we do need the words that are enclosed by those em markers, and that’s the second element in the Find, so we type \2 to tell the second thing found to be replaced by itself.