Archive for the ‘Word’ Category

h1

Word: Add padding to a character style

May 29, 2017

My client wanted the button text in the user manual I was writing to look similar to the buttons in the app. For this app, blue, green, and orange background colours were used for the buttons, with white text.

Easy enough to do — just set up three Word character styles, one for each colour, have different coloured shading for each, and bold white text for the font. Make it simple for both writing and future updating by assigning keyboard shortcuts for each style. Done.

But, while my client liked what I’d done, he was concerned that the first and last letter of the button text butted up against the edge of the coloured shading (see image below), and wanted to know if we could add some padding.

I was pretty sure I could do that to a character style using borders the same colour, but then I ran into an issue I’d never seen before. When I applied a border of any weight or colour, I lost the background shading for the text. In the example below, you can see that the area inside the blue border has white space inside it, not blue shading with white text as I expected.

No matter what I did, I couldn’t get it to work. I explained the situation to my client. Fortunately, he’s a programmer and knows a bug when he sees one :-) He did a little bit of experimenting and came up with the solution, which was to reapply the background shading to the character style AFTER adding the border.

It worked, and here’s the end result (it has a 1.5 pt border, just enough to add a bit of padding to both ends of the text, but not too much that the top and bottom padding adds too much gap between lines in a paragraph):

h1

Word: Copy AutoCorrect entries to another computer

May 3, 2017

Did you know you can copy your AutoCorrect entries from one computer to another? You might want to share yours with a work colleague, or you might have a new computer and not want to set them all up again.

Beware: Copying these files to another computer WILL overwrite the AutoCorrect files in the destination computer, so if you’re copying them to a colleague’s computer, make sure they have listed their own AutoCorrect entries first (see https://cybertext.wordpress.com/2017/05/03/word-list-keyboard-shortcuts-autotext-and-autocorrect-entries/).

Notes:

Your AutoCorrect entries apply to all programs in the Microsoft Office suite, and are stored in *.ACL files under your user profile on your computer. When you copy them, you’ll put them in the same place but under the other user’s profile on their computer.

  1. On your computer, go to: C:\Users\[your_user_name]\AppData\Roaming\Microsoft\Office.
  2. You’ll see a suite of ACL files listed. The MSO numbers in each file name indicate the language/locale; e.g. MSO0127.acl = Math, MSO1033.acl = English (US), MSO2057.acl = English, (UK), MSO3081.acl = English (Australia). (For a full list of locale numbers, see: http://support.microsoft.com/en-us/help/221435/list-of-supported-locale-identifiers-in-word.) Hint: Look at the date last modified — the ACL files with the most recent dates are likely the ones your installation of Office uses.
  3. Copy the ACL files you need (or copy them all if you’re not sure and they’re going to a new computer).
  4. On the destination computer, go to: C:\Users\[user_name_of_other person]\AppData\Roaming\Microsoft\Office.
  5. Paste the copied files into this folder, saying yes to overwrite the existing files.

[Links last checked May 2017]

h1

Word: List keyboard shortcuts, autotext, and autocorrect entries

May 3, 2017

There are many things you can do to help automate the writing and editing process. Power users of Word use keyboard shortcuts extensively — either the in-built ones that come with Word (e.g. Ctrl+s to save, Ctrl+c to copy etc.), or ones they’ve created themselves. Power users also use AutoText and AutoCorrect to speed up inserting commonly used text, tables, etc. (See the links below for some of the blog posts I’ve written on all these.)

But how do you know what you’ve got available to use? Some of the more obscure in-built keyboard commands are difficult to find listed anywhere, and how do you remember which ones you’ve created for your own use? How can you get a list of these shortcuts, and a list of your AutoText and AutoCorrect entries? Of course, once you have a list you can then save it or print it out to refer to at any time.

I used Microsoft Word 2010 for Windows when writing this blog post — the same (or very similar) information should apply to later versions of Word for Windows. Mac users — you may be able to do this too, but as I don’t own a Mac, I can’t test on a Mac or write about Mac stuff.

List all in-built Microsoft Word keyboard commands

  1. Open a blank Word document.
  2. Go to the View tab and click the large Macros icon.
  3. Click the drop-down arrow for the Macros in list, then select Word commands.
  4. Select ListCommands in the top box.
  5. Click Run.

List all custom keyboard commands

  1. Open a Word document that is based on the template where you know the custom keyboard commands are stored (if stored in Normal, just open a blank Word document).
  2. Go to the File tab and select Print.
  3. Under Settings, change from the default Print All Pages to Key Assignments.
  4. Choose your printer (e.g. PDF if you want a document to save), then click Print.

List all AutoText entries

  1. Open a blank Word document.
  2. Go to the File tab and select Print.
  3. Under Settings, change from the default Print All Pages to AutoText Entries.
  4. Choose your printer (e.g. PDF if you want a document to save), then click Print.

List all AutoCorrect entries

Use the macro described here: http://wordribbon.tips.net/T009084_Printing_a_List_of_AutoCorrect_Entries

See also:

[Links last checked May 2017]

h1

Word: Macro to add a value at the beginning of each row of a table

May 2, 2017

I had a strange request — someone had a really long table in Microsoft Word (some 50+ pages long…) and wanted to add an asterisk (star) in front of the first character in each row, no matter how many rows and columns there were in the table or what the original first character in each row was (some first characters were numerals, but most were upper or lower case letters). Doing this manually was going to take hours, and he had several tables across various documents that he wanted to do this to.

My first thought was a find and replace with wildcards routine, but I quickly figured out that I didn’t have enough knowledge to do that, even if it was possible. My next thought was to add a new first column, populate it with asterisks, then merge the first and second columns of each row — the problem was that merging required selecting each pair of 1st and 2nd column cells for EACH row, then merging, then removing the added paragraph mark created by the merge process. That was going to take as long or even longer than adding the asterisks manually!

So I contacted my friend Dave Gash (www.davegash.com), a US-based programmer/tech writer, to see if he could help. His forte isn’t VBA, but he does know programming logic (and he knows what to search for), and by the next morning he had a solution for me. Actually he had a solution that was TOO good — his first solution (Macro 2 below) added the asterisk to the beginning of all rows in ALL tables in the document. But that’s not what my client wanted — he wanted to add asterisks to all rows in a specific table, not every table. A bit of tweaking and Dave came back a few minutes later with the solution that suited my client (Macro 1 below). When I ran it in test mode, the changes were almost instant, but they took about 5 mins on the 50+ page table! That was still many hours less than it would’ve taken manually. I owe Dave a beer or three!

Macro 1: Add an asterisk to the beginning of all rows in a specific table

Sub AddAsteriskToTableRow()
   ' From Dave Gash www.davegash.com April 2017 '
   ' Collapse the range to start so as to not have to deal with '
   ' multi-segment ranges. Then check if cursor is within a table. '

   Selection.Collapse Direction:=wdCollapseStart
   If Not Selection.Information(wdWithInTable) Then
      MsgBox "You can only run this when your cursor is within a table."
      Exit Sub
   End If

   ' Process every row in the current table. '
   Dim row As Integer
   Dim rng As Range

   For row = 1 To Selection.Tables(1).Rows.Count
      ' Get the range for the leftmost cell. '
      Set rng = Selection.Tables(1).Rows(row).Cells(1).Range

      ' For each, insert asterisk in leftmost cell.'
      ' Change value in quote marks if you want something other than an asterisk. '
      rng.InsertBefore ("*")
   Next
End Sub

Macro 2: Add an asterisk to the beginning of all rows in ALL tables in a document

Sub AddAsterisksToAllTables()
    
' From Dave Gash www.davegash.com April 2017
' Loop through all tables
For tbl = 1 To ActiveDocument.Tables.Count
 
    'Set up row and range vars
    Dim row As Integer
    Dim rng As Range
 
    'Loop through rows in current table
    For row = 1 To ActiveDocument.Tables(tbl).Rows.Count
        ' Get the range for the leftmost (column 1) cell
        Set rng = ActiveDocument.Tables(tbl).Rows(row).Cells(1).Range
        ' Insert the asterisk before the text in leftmost cell
        ' Change value in quote marks if you want something
        ' other than an asterisk.
        rng.InsertBefore ("*") 
    Next row 
Next tbl 
End Sub

Notes

  • The examples above use an asterisk as the added character, but you can make that character anything you want — one or more letters or numbers or standard punctuation symbols (or a combination), with or without a space. Just change the value in the double-quotation marks in the macro to what you want (e.g. you might have a list of product numbers that need to have ‘MQ’ added in front of them — change “*” to “MQ” [or “MQ-” or “MQ “]). You might want to change the name of the macro too, to reflect what you’re adding (e.g. AddMQToTableRow).
  • Don’t run this twice in the same table, otherwise you’ll end up with two asterisks!
  • Dave asked me to add this acknowledgement: ‘My source was from a StackOverflow (the coder’s friend, believe me!) member (apparently also from Western Australia!). … I modified the code I found there for your purposes.’ Source: http://stackoverflow.com/questions/7226721/how-can-you-get-the-current-table-in-ms-word-vba

[Links last checked May 2017]

h1

Word: Unlock a password-protected document

April 18, 2017

I spotted this 2009 article (http://people.csail.mit.edu/teller/misc/unlockworddoc.html) a few weeks ago, and have now had time to test it — it works!

Now, why would you want to unlock a password-protected Word document? Surely the author/company has locked it for a reason? Yes, in many cases, that’s correct and you shouldn’t try to circumvent the password protection — instead, ask the author/company for the password if you need to access elements of the document (e.g. protected form fields, formatting tools etc.).

However, if the author has left the company, or if they wrote the document many years ago and have forgotten the password (it happens!), then you may need to break the password protection to access the document’s contents and functions.

You can follow the steps in the link above, or, in case the content at that link gets removed at any stage, follow my modified and more detailed steps below, which are based on that article:

  1. Open the password-protected document in Word.
  2. Go to File > Save As, then select Word XML Document (*.xml) from the Save as type drop-down list.
    Select Word XML Document from the Save as Type drop-down list
  3. Click Save.
  4. Close Word.
  5. Right-click on the saved XML file (it should be in the same folder as your original document), then select Open with and choose a text editing program to open the file with (e.g. WordPad, NotePad, or other text editing program — do NOT choose Microsoft Word).
  6. Press Ctrl+F to open the Find dialog box.
  7. In the Find what field, type enforcement.
  8. You’ll find one instance, either w:enforcement=”1″ or w:enforcement=”on”.
    Find 'enforcement'
  9. Replace the “1” with a zero “0” (or replace “on” with “off”) to disable enforcement. This step unlocks the document.
  10. Save the XML document within your text editor, then close the text editing software.
  11. Right-click on the saved XML file, then select Open with and choose Microsoft Word.
  12. As soon as you’ve opened it, go to File > Save As, then select Word Document (*.docx) from the Save as type drop-down list. Change the file name if you want to preserve the original password-protected document an make this a new document, or use the same file name to replace the original document.
  13. Click Save. You should now be able to edit the document.

[Link last checked April 2017]

h1

Word: Find and replace multiple spaces after punctuation

December 21, 2016

You receive a document that has multiple spaces after standard punctuation — periods, commas, semicolons, colons, question marks, and exclamation marks. Sometimes the author used two spaces, sometimes three, sometimes five!

How to fix it?

Well, you can run several find/replace routines but as the number of spaces is unknown and as there are many types of punctuation, that could take quite a lot of time. Instead, you can use a wildcard find/replace routine to find them all at once, keep the punctuation, and replace the unknown number of spaces with a single space. Here’s how (for your own peace of mind, test this on a COPY of your document first):

  1. Press Ctrl+H to open the Find and Replace dialog box.
  2. Click the More button to show more find/replace options.
  3. Select the Use wildcards checkbox.
  4. In the Find what field, type: ([,.;:\?\!])( {2,9})
    NOTE: There’s a single space before the {2 — make sure you include that. To be safe, copy the ‘code’ in this step, and paste it into your Find what field.
  5. In the Replace with field, type: \1 followed immediately by a single space.
  6. Click Find Next to find the first instance, then Replace to replace the multiple spaces with a single space.
  7. Repeat step 6 as many times as you need to be confident that it’s finding the right things. Once you’re confident, click Replace All to run through the whole document and fix all instances.

Use wildcards to find and replace multiple spaces after defined punctation

Explanation for how this works:

  • ([,.;:\?\!]) looks for any of the listed punctuation characters. Question and exclamation marks are special cases and need to be ‘escaped’ with a \. Because you’re using wildcards, you need to surround the text you want to find in parentheses. This string defines the first section of the Find.
  • ( {2-9}) looks for a space followed by two or more spaces, up to 9 spaces (you can put whatever numbers you like inside the curly braces — if you think you might have some instances of punctuation followed by 15 spaces, then change these numbers to {2-20}, for example. Again, this section is surrounded by parentheses to define it as a separate section.
  • \1 replaces the first part of the wildcard string with itself. In other words, the punctuation character found is replaced with itself, so no change apparently occurs.
  • The space after \1 replaces the multiple spaces found in the second part of the wildcard string with a single space.
h1

Word: Cross-Reference Manager add-in: Review

August 26, 2016

Back in 2010, I wrote a blog post pleading with Microsoft to fix/enhance the cross-reference functionality in Word. Others commented on that post, offering their own suggestions and venting their frustrations with it as well.

Well, someone did see that post and has done something about it, though they aren’t from Microsoft. Lene Fredborg from DocTools (and a Microsoft Word MVP) has written a Cross-reference Manager (CRM) add-in to Word that addresses all my woes, and more. It costs just under US$50 per license for 1 to 4 licenses, and the price per license goes down the more licenses you buy.

Several months ago, Lene asked me to beta test the add-in and make suggestions. Anyone who’s done beta testing knows that process takes longer than expected with the to-ing and fro-ing over time. My tests were done on a 200+ page, 73,000-word document that had more than 350 cross-references, so I really put it through its paces! Lene released the final version in July.

In the interests of transparency, yes, because of my contribution via beta testing I have a free license for my copy of the add-in, but I was not asked to do this review, nor do I receive any financial benefit from it. My aim is to let my readers know that it exists and to test it out for themselves (there’s a 15-day free trial period).

So, on to the review…

Who is the add-in for?

This add-in is for anyone using Microsoft Word on a PC (NOT Mac or tablet versions), from Word 2007 onwards. For those of us who work with long complex Word documents where we use automated caption numbering, outline heading numbering, and the like, and need to insert multiple automated cross-references (to tables, figures, sections, appendices, references etc.) into our documents, CRM is a major improvement on Microsoft’s Cross-reference dialog box.

However, if you don’t use cross-references, or only do a few per document, CRM is probably not for you.

What happens to my ribbon?

Once installed, CRM doesn’t replace the in-built Cross-reference dialog box; instead, it lives on a new DocTools tab (Manage Cross-references group) on the ribbon. You can use whichever you prefer — you aren’t forced to use one or the other.

You can add the functions on the DocTools ribbon to the Quick Access Toolbar by right-clicking on the function and selecting Add to Quick Access Toolbar.

Note: DocTools makes other Word add-ins, which get added to the same ribbon but in different groups.

What does it do?

CRM adds a huge amount of functionality to cross-referencing in Word. Essentially, it’s cross-referencing on steroids! It addresses most (all?) of the issues I raised in that post from 2010, and issues raised in several of the comments on that post, as well as other issues that frustrated Lene.

There are three icons in the Manage Cross-references group of the DocTools tab:

  • Insert Cross-references:
    • Use this instead of the standard Microsoft dialog box.
    • Has a filter function to just show items with the character you type (e.g. type ‘3’ to see all Headings with a ‘3’ in their outline numbering, such as 2.3, 2.13, 3.1, 3.2, etc.)
    • Can resize the dialog box and increase the number of items displayed at once.
    • Can set your cross-reference defaults from this screen (as well as via Tools).
    • Target types don’t separate Figures, Tables, Equations — the more sensible Captions is used, and then you select the type of caption.
    • Your most recent settings are retained for the next cross-reference you add.
  • Cross-reference Tools:
    • All sorts of functions to identify and fix broken cross-references. (Note: Any highlighting you add/remove via the tools will NOT change any existing highlighting you’ve added to the document for other purposes.)
    • Set defaults for the Insert Cross-references dialog box.
    • Set custom text to go in front of a cross-reference (e.g. ‘See Section’ xx.xx; ‘Refer to’ Table xx-xx; etc.)
    • Update all fields.
    • Toggle display settings for field shading, bookmarks etc. (much quicker than doing it via Word’s Options dialog box)
    • And many many more…. (see the More Details tab on the webpage for CRM for full descriptions of all functions, screenshots etc.: http://www.wordaddins.com/products/cross-references-word_doctools-crossreferencemanager/)
  • Help: Lene has written a very comprehensive Help file to go with CRM. Read it to see all the things CRM can do — I only skim over the main functions in this review.

Summary

This is a terrific add-in that improves on Microsoft’s own cross-referencing function, and makes it much easier to assign cross-references. It’s a great tool for all power Word users.

I highly recommend it.