h1

Word: Macro to set the language for ALL styles

September 21, 2018

One of the issues with setting the language for a Word document is that DOESN’T change the language set for the styles. If you’re lucky, your styles use the same language as your default language, but sometimes they don’t (especially if the document has come from authors in other countries). This can result in some strange behaviour under specific circumstances.

I have a macro for setting the language for all ‘ranges’ in a document, but I needed something to change the language settings for ALL styles in one command. After a bit of internet sleuthing, I came across an answer that looked promising and modified it to suit my purposes. It works! I tested it on a sample document, where I’d set the language for Normal to Alsatian, for Heading 1 to Afrikaans, and for Heading 2 to English (US). The only text I had in the document used Normal style, but that didn’t matter—the language settings for the styles still changed to the one I’d specified in the macro. In my case, that’s English (Australian) [in VBA code that’s wdEnglishAUS].

The only thing you need to change in this macro is the LanguageID. Here are some common ones for English:

  • wdEnglishAUS
  • wdEnglishCanadian
  • wdNewZealand
  • wdEnglishSouthAfrica
  • wdEnglishUK
  • wdEnglishUS.

Here’s the macro (copy it—some of it may go off the page, so if you type it you may miss some):

Sub ChangeLangStyles()

' Macro to change language in styles
' Adapted from Macropod (17 July 2012)
' http://www.vbaexpress.com/forum/showthread.php?42993-Solved-Macro-to-change-all-styles-to-a-specific-language

Dim oDoc As Document, oSty As Style
Set oDoc = ActiveDocument
    With oDoc
        For Each oSty In .Styles
            On Error Resume Next
            oSty.LanguageID = wdEnglishAUS
            On Error GoTo 0
        Next
    End With
End Sub

I adapted it from one shared by Macropod back in July 2012: http://www.vbaexpress.com/forum/showthread.php?42993-Solved-Macro-to-change-all-styles-to-a-specific-language, and full acknowledgement goes to him.

[Links last checked September 2018]

h1

Word: Find ‘ing’ words and change their formatting

September 21, 2018

Tessa had a problem—she needed to find all words ending in ‘ing’ in her document and format the whole word in some way.

NOTE: This find/replace will find ALL words ending in ‘ing’, but not words ending in ‘ings’ or ‘ingly’. And words such as ‘going’, ‘bring’, ‘sing’, ‘king’, and ‘thing’ also get found. But if your aim is to find ALL words ending in ‘ing’ that’s what you’ll get.

Simplest solution: If you didn’t want the whole word to be formatted, just the ‘ing’ bit, then it’s easiest to use the standard find/replace, with the ‘Match Suffix’ option turned on. See Method 1 below.

However, if you want the whole words found and formatted, you’ll need to use wildcards. See Method 2 below.

Method 1

  1. Open the Find and Replace window (Ctrl+h).
  2. Click More to see the extra search options.
  3. In the ‘Find what’ field, type ing
  4. Select the Match suffix checkbox.
  5. Put your cursor in the ‘Replace with’ field, then click Format at the bottom of the window.
  6. Click Font.
  7. Select the formatting you want to apply to the found ‘ing’s—you can choose one or more options from this window. Then click OK to close the Font window. The formatting you selected is listed below the empty ‘Replace with’ field.
  8. Click Find Next, then click Replace as many times as you need to be comfortable that the find/replace works as you want it to. If you’re happy with the matches, then click Replace All.

Method 2

This method uses Word’s find and replace with wildcards.

  1. Open the Find and Replace window (Ctrl+h).
  2. Click More to see the extra search options.
  3. Select the Use wildcards checkbox.
  4. In the ‘Find what’ field, type <[A-Za-z]@ing>
  5. Put your cursor in the ‘Replace with’ field, then click Format at the bottom of the window.
  6. Click Font.
  7. Select the formatting you want to apply to the found ‘ing’ words—you can choose one or more options from this window. Then click OK to close the Font window. The formatting you selected is listed below the empty ‘Replace with’ field.
  8. Click Find Next, then click Replace as many times as you need to be comfortable that the find/replace works as you want it to. If you’re happy with the matches, then click Replace All.

How this wildcard find/replace works:

  • < and > represent the start (<) and end (>) of a word (this specifies that you’re looking for a whole word)
  • [A-Za-z] look for any upper any lower case letters
  • @ing tells Word to repeat looking for upper/lower case letters until it finds ing

What about ‘ing’ in the middle of a word?

Follow Steps 1 to 3 in Method 2 above, then in the ‘Find what’ field, type <[A-z]@ing[a-z]@>. Continue with Steps 5 to 8 above.

NOTE: You can’t format just a part of the replace (i.e. you can’t make just the ‘ing’ in ‘fringed’ red or bold)—it’s all or nothing.

h1

Outlook: Spellcheck not working

September 18, 2018

I was working on my laptop, which has Office 2016 installed on it. Spellcheck worked fine in Word, but when I was in Outlook, no spelling errors were flagged. When I looked at the spellcheck settings in Outlook, all options were greyed out and unavailable. I couldn’t turn it on or off, or change anything else.

I consulted Dr Google, and found that a possible reason was a different version of Outlook and Word (see https://answers.microsoft.com/en-us/msoffice/forum/msoffice_outlook-mso_other-mso_2016/outlook-2016-spellcheck-option-greyed-out/13c5c4f6-3735-4836-9e74-61eb9a6ddae5)

But I had installed Office 2016, so they should be the same version, right? And then I remembered something from way back when… When I installed Office 2016 on my laptop, I couldn’t connect to Exchange Server (which is part of Small Business Server [SBS] 2008) from Outlook. My IT guys told me the reason was that Outlook 2016 was incompatible with Exchange Server 2008, so with their help I’d uninstalled Outlook 2016 and reinstalled my earlier Outlook 2013.

I checked the properties of both Outlook and Word to see which version I was using. Unfortunately, Microsoft no longer has an ‘About’ option; instead, go to File > Account or Help and you should be able to find your version. If they are different (i.e. Outlook’s version starts with 14 [Office 2010], or 15 [Office 2013] and the Word version starts with 16 [Office 2016]), you now know that spellcheck won’t work in Outlook.

Personally, I think this is a bug. If the proofing tools (i.e. spellcheck) are associated with a version folder on the PC, then it shouldn’t matter whether you’ve opened Word or Outlook—the programs should use the proofing tools specific to that version. Yes, the words you’ve added to each may not be available to the other, but they should still point to the applicable proofing tools for the version. However, according to the information in the link above, it’s winword.exe that’s loaded for the spellcheck, NOT the proofing tools. So if winword.exe is in a different Office folder to Outlook (e.g. office 16 versus Office 15), Outlook can’t find the spellcheck tools. Go figure.

[Links last checked September 2018]

 

h1

Word: AutoCorrect entries not working on some documents

September 18, 2018

I use Word’s AutoCorrect function a lot. I mean, a LOT. So I’ve been flummoxed when occasionally it doesn’t work. I type in my code and it won’t expand to the text I have assigned to that code. It works in all other documents, new and old, and it makes no difference whether those documents are stored locally or on the server. It just doesn’t work in SOME documents.

Today I decided to get to the bottom of it and see if there was a solution — and there is. I had to hunt various Word forums and try several things, but one of the suggested solutions pointed me in the right direction, and with a bit of trial and error I found the answer.

But first, a bit of background so you understand something about autocorrect (ACL) files and their relationship to the language settings in your document. You have several ACL files on your system (in Windows, they’re under C:\Users\<username>\AppData\Roaming\Office). Each ACL file has a number that corresponds to a language (e.g. MSO1033 for US English, MSO2057 for UK English, MSO3081 for Australian English, and so on). The language you have set on your computer AND for Word should be the same, and the language for the document you’re working on dictates where any ACL entries you create while working on that document will go (at least, I think that’s the case). So, if you’ve got Australian English set as your computer and Word language, but are working on a document set for US English, then your autocorrects may not work, and new ones may save to the US ACL file. If you want to know what language your autocorrects are set to, go to File > Options > Proofing > AutoCorrect Settings — the language is displayed in the title bar of that window.

Now, how to solve it…

The simplest solution is to set the language for the whole document to your preferred language (Ctrl+A, Review tab, Language, then set the proofing language and turn off the Detect Language Automatically check box). If your autocorrects start working again, you’re done.

If they don’t, as happened to me, then you need to delve a little deeper. Selecting the entire document and changing the language doesn’t change the language for everything in Word, just some of the visible bits. For example, it doesn’t change the language set in the styles. And this is where I started investigating and found the answer. For the document I was working on, most of the styles were based on Normal, so I checked the settings for the Normal style and found that the language for that style was set to US English. I changed the language for that style to Australian English, and suddenly my autocorrects starting working straight away! NOTE: If you have lots of styles based on (none), then you’ll have to modify each style and set its language.

The solution was simple, but the path to find the solution wan’t!

Note: This forum post helped me find the answer (see the comment from Jay Freeman on page 2 dated 10 January 2017): https://answers.microsoft.com/en-us/office/forum/office_2013_release-word/word-2013-autocorrect-stopped-working-mid-document/655258c4-a307-4b5d-a8d6-d81a146a8b39?db=5

[Links last checked September 2018]

h1

Windows: 100% disk usage

September 15, 2018

A few weeks ago one of our computers had a 100% disk usage issue. I can’t remember how my IT guys solved it, or the cause, but they did.

If you have the same issue, then try the instructions in this YouTube video: https://www.youtube.com/watch?v=mqbg4-3LIOQ — the critical information starts about 1 min 50 secs into the video.

To summarise the video:

  1. Open Resource Monitor, and check the Disk tab for what’s using the most resources.
  2. If it’s something called DiagTrack (with a bunch more information), open Task Manager, go to the Services tab, and stop DiagTrack (the Description has something like Connected User Services and Telemetry). This stops it from running for now, but when you reboot, it will likely start again.
  3. To stop it for good, you need to disable it. Open Services.msc, and find Connected User Services and Telemetry. Right-click on it and open Properties.
  4. Select Disabled from the Startup Type drop-down list, then click Apply and OK.
  5. Check Task Manager again to see if your system resources have been freed up.
  6. Reboot your computer.

[Link last checked September 2018]

 

h1

Word: Make some specific text bold

September 14, 2018

As most people would know, you can apply bold formatting in Word using Ctrl+b or the Bold icon on the Home table on the Ribbon.

But what if you want more? What if you have some specific text scattered throughout your document that you want to make bold in one action? This was the issue Colin faced. In a comment on one of my other blog posts, Colin asked if there was a way to apply bold a set of characters that all started with the same code, but had different numbers after that code (e.g. like product codes). In his example, he had a lot of instances of VA-001, VA-002, etc. with the last three digits being different each time. He’d tried the method I’d documented in my earlier post, but he could only bold part of the code, not all of it.

As with any find and replace, once you identify the pattern, it’s easy enough to test various ways of finding a match and then applying the change to it. I figured out two methods—both using wildcards. The first method assumes there are only ever three characters (not, 1, 2, 4, etc.) after the VA- part, while the second applies to any length of the ‘word’ after VA-.

For both methods, open the Find and Replace window (Ctrl+h), click More, then check the option for Use wildcards.

Method 1: Only three characters

  1. In the Find field, type: (VA-)(???)
  2. In the Replace with field, type: \1\2
  3. With your cursor still in the Replace with field, click Format, then Font, then select Bold. You should see Font: Bold directly below the Replace with field (see screenshot).
  4. Click Replace a few times to make sure the find/replace is doing what you expect it to. Once you are satisfied, you can click Replace All.

Notes:

  • In the Find, the code is separated into two parts, both surrounded by parentheses—the VA- part, which is a constant in what Colin had, and three question marks (???). A single question mark represents any single character, so by typing three question marks, you’re asking Word to look for ANY three characters (letters and/or numbers) after the VA- part. If you only had two characters, then you’d type two question marks; if you had 4, then you’d type four, etc.
  • In the Replace, you’re replacing what was found in both parts with itself. In other words, you’re not changing anything. What you are doing in the Replace, though, is specifying that what you find and replace with itself is now bold (step 3).

Method 2: Any number of characters

  1. In the Find field, type: (VA-)(*>)
  2. In the Replace with field, type: \1\2
  3. With your cursor still in the Replace with field, click Format, then Font, then select Bold. You should see Font: Bold directly below the Replace with field (see screenshot).
  4. Click Replace a few times to make sure the find/replace is doing what you expect it to. Once you are satisfied, you can click Replace All.

Notes:

  • In the Find, the code is separated into two parts, both surrounded by parentheses—the VA- part, which is a constant in what Colin had, and an asterisk followed by a right chevron arrow. The asterisk represents any number of characters from one to infinity. Because a ‘character’ in Word could be a space, you don’t want it to find EVERY character after the VA- part—you’d get the whole document! So you add the > to tell Word to stop at the end of the ‘word’ it finds. In other words, it will stop at any character that typically follows a set of adjacent characters (a ‘word’), such as a space, period, comma, colon, semicolon, etc.
  • In the Replace, you’re replacing what was found in both parts with itself. In other words, you’re not changing anything. What you are doing in the Replace, though, is specifying that what you find and replace with itself is now bold (step 3).

[Links lat checked September 2018]

h1

Word: Macro to convert from one style to another

September 11, 2018

I should have hunted this out years ago. My main client has a habit of changing templates every couple of years, which means the old docs have to go onto the current template when they get revised. It’s a pain and involves quite a few steps (and up to several hours) per document. I still have to do the cover page and headers/footers manually, and all the landscape/portrait sections, but now I’ve got a way to convert styles in the older template to differently named styles in the newer template. For styles with the same name, no such conversion is necessary, but when the old style is called ‘Table Bullet 1’ and the new one is called ‘Table Bullet’ you have to either reapply the correct style everywhere it is used (ugh!), do a global find and replace for the style, or do a ‘select all’ for the style and then click the new style to apply it.

Some caveats:

  • Test first. Test on a COPY of the old document before doing it on the original copy, and any other documents in the set.
  • Make sure you’ve applied the new template to the old document so that the new styles are available in the document. (or, use the Organizer to copy styles across from the old template to the new [longer, slower method]).
  • Make a list of the old styles and the matching, but differently named, new styles—make sure you write down the style names EXACTLY (including any hyphens in the style name) otherwise this macro won’t work.
  • This macro runs a find and replace and replaces ALL. Test first.

Acknowledgements: I modified the macro written by Christina and available from here: https://stackoverflow.com/questions/29953322/changing-styles-in-word-using-vba to suit my client’s situation.

In my modified macro below, several styles used in tables had name changes, as did one for the appendix headings. You can add more for your circumstances—just make sure you add a new ‘Set’ line with a unique name, call that name in a separate ‘With’ statement, and make sure you add that name to the ‘Dim’ statement at the top of the macro.

If you want to use/modify this macro, copy/paste the code below–some of it runs off the page, so if you retype the code you may miss some critical command. Then modify the Set names (if required) and the style names in the double quotes.

Sub FNR_Styles()

' Converts old table and Appendix styles to new using find and replace
' Rhonda Bracey, 11 Sept 2018 (modified from https://stackoverflow.com/questions/29953322/changing-styles-in-word-using-vba [Christina])

Dim objDoc As Document
Dim table1 As Style, table2 As Style, table3 As Style, table4 As Style, app1 As Style

Set objDoc = ActiveDocument
' This code does *NOT* protect against the possibility that these styles don't
' appear in the document. That's probably not a concern with built-in styles,
' but be aware of that if you want to expand upon this for other uses.
' Set up as many of these as you need, giving each a unique name.
' The style name in the quote marks is the NEW style name.
' Make sure you add the name to the second Dim row at the top of the macro as well.

Set table1 = ActiveDocument.Styles("Table Text")
Set table2 = ActiveDocument.Styles("Table Bullet")
Set table3 = ActiveDocument.Styles("Table Heading White")
Set table4 = ActiveDocument.Styles("Table Text Number")
Set app1 = ActiveDocument.Styles("Appendix Heading")

' Searches the entire document (but not foot/endnotes, headers, or footers)
' for the old style and replaces it with the new style.

With objDoc.Content.Find
    .ClearFormatting
    .Style = "Table Text - Left"
    ' The style in the quote marks is the OLD style name
    With .Replacement
    .ClearFormatting
    .Style = table1
    End With
    ' Below is the Replace All command.
    ' Could change this to Replace:=wdReplaceOne to replace one only
   
    .Execute Wrap:=wdFindContinue, Format:=True, Replace:=wdReplaceAll
End With

With objDoc.Content.Find
    .ClearFormatting
    .Style = "Table Bullet 1"
    With .Replacement
    .ClearFormatting
    .Style = table2
    End With
    .Execute Wrap:=wdFindContinue, Format:=True, Replace:=wdReplaceAll
End With
With objDoc.Content.Find
    .ClearFormatting
    .Style = "Table Head - Center"
    With .Replacement
    .ClearFormatting
    .Style = table3
    End With
    .Execute Wrap:=wdFindContinue, Format:=True, Replace:=wdReplaceAll
End With
With objDoc.Content.Find
    .ClearFormatting
    .Style = "Table Text - Number"
    With .Replacement
    .ClearFormatting
    .Style = table4
    End With
    .Execute Wrap:=wdFindContinue, Format:=True, Replace:=wdReplaceAll
End With
With objDoc.Content.Find
    .ClearFormatting
    .Style = "App H1"
    With .Replacement
    .ClearFormatting
    .Style = app1
    End With
    .Execute Wrap:=wdFindContinue, Format:=True, Replace:=wdReplaceAll
 End With

End Sub