Getting Help with Macros

By Jack Lyon, the Editorium

While messing about with macros, I sometimes find myself up against a problem for which I have no solution. Time to get some help!

My usual approach is to use Google to search for "microsoft word vba [whatever problem I'm having]".

That turns up lots of interesting stuff, but the best answers are usually found in just a handful of places:

All of those have "Search" bars of their own, so you can search directly within those places for what you need.

The most reliable answers in those forums are usually given by the ever-helpful Microsoft MVPs, past and present. In particular, watch for answers from these folks:

  • Suzanne S. Barnhill
  • Paul Edstein
  • Terry Farrell
  • John McGhie
  • Charles Kenyon
  • Greg Maxey
  • Graham Mayor

And don't forget to say "Thank you!"


Readers Write

After reading last week's article, "Writing Down the Chaos," which discussed writing with notecard-based software, Kirsten Janene-Nelson wrote:

I use Scrivener. You can organize by cards with their "Corkboard" feature as well as seamlessly switch to manuscript view. There's a bit of a learning curve, but it's pretty painless and they have several helpful videos. My favorite feature is that you can keep all the moving parts of what you're writing close at hand without their being in your face. It's a virtual writing desk plus bulletin board plus project binder—all in one.

It's $59 after 30 days' trial—not 30 calendar days from when you start, but 30 actual days that you use Scrivener, regardless of when you start. https://www.literatureandlatte.com/scrivener

Thanks to Kirsten for this information. If you're serious about writing, Scrivener may be the very program you need to produce your masterpiece.

How to Add a Macro to Word and Its QAT (Quick Access Toolbar)

Microsoft Word's macro features make it possible to turn Word into a lean, mean editing machine. You'll find lots of free editing macros online (see below for some excellent sources). But how can you add a macro to Microsoft Word so it will be available when you need it? Here's the procedure:

  1. Copy the text of the macro, starting with the first “Sub” and ending with the last “Sub.”
  2. Click the “View” tab on Microsoft Word’s ribbon.
  3. Click the “Macros” button.
  4. Type a name for the macro in the “Macro name” box—probably the name used after the first “Sub.”
  5. Click the “Create” button.
  6. Delete the “Sub” and “End Sub” lines that Word created in the macro window. The macro window should now be completely empty (unless you already have other macros in there).
  7. Paste the macro text at the current insertion point.
  8. Click “File,” then “Close and Return to Microsoft Word.”

To actually use the macro:

  1. Place your cursor at the beginning of the document.
  2. Click the “View” tab on Microsoft Word’s ribbon.
  3. Click the “Macros” button.
  4. Click the name of your macro to select it.
  5. Click the “Run” button. (If you wanted to delete the macro, you could press the “Delete” button instead.)

To put the macro on Word’s QAT (Quick Access Toolbar):

  1. Locate the QAT (it’s probably on the top left of your screen either above or below Word’s Ribbon interface).
  2. Right-click the QAT.
  3. Click “Customize Quick Access Toolbar.”
  4. Under “Choose commands from:” click the dropdown list and select “Macros.”
  5. Find and select your macro in the list on the left.
  6. Click the “Add” button to add it to the QAT.
  7. Click the “OK” button to finish.

Writing Down the Chaos

By Jack Lyon, the Editorium

You can't do much carpentry with your bare hands, and you can't do much thinking with your bare brain. —Bo Dahlbom

High school English class. Freshman year. The teacher explained how to:

  1. Come up with a thesis statement.
  2. Create an outline of arguments supporting the thesis statement.
  3. Write a paper based on that outline.

That's actually a terrible way to write! It requires you to organize your thoughts before you know what those thoughts actually are. But there is a better way.

Brainstorm, Organize, Write

What are your thoughts about a particular subject? In the days before computers, you'd find out like this:

  1. Get a package of index cards, something like these.
  2. On each card, write an idea related to your thesis (the fancy word for whatever it is you want to write about). Do not try to do this in any kind of order; you're brainstorming here: good ideas, bad ideas, any ideas—they all go down on the cards. When your brain is empty, stop.
  3. On a big desk or table, spread the cards out in front of you. Keep them messy.
  4. Read the cards and stack those on a certain subject together until you have several stacks. Discard (pardon the pun) those that don't belong anywhere or that now seem irrelevant or stupid.
  5. Put the cards in each stack in some kind of order. Importance? Chronology? You choose.
  6. Put the stacks in some kind of order. Each stack represents a section of your paper.

After you've captured and organized your thoughts, write your paper, starting with the first card and ending with the last. Each stack gets a subheading. Each card gets a paragraph. When you're finished, edit your paper as needed.

Card-Based Writing Programs

But, again, that was in the days before computers. We now have much better ways of doing what I've just described, with new card-based writing programs popping up all the time. Here are some that I recommend for the kind of writing I've explained in this article:

Milanote. $9.99 a month (billed annually).

img

Milanote is the most expensive of the programs listed here, but it's also the slickest. Cards can be created and then placed on the screen in any order you like. After you have them all down, organize them into columns. Finally, export the whole thing as a Word document, a Markdown document, or plain text, ready for editing. Milanote is elegant, a pleasure to use.

Speare. $4.95 a month (billed annually).

img

Speare doesn't support free-form card placement; each paragraph is a card, and all cards must be arranged in a "board." After creating and organizing your cards, "compile" them into a document, copy the document, and paste into Word or another word processor.

SuperNotecard. $19 a year.

img

SuperNotecard includes various kinds of metadata you can use to organize your cards: headings, flags, ratings, categories, references, and much more. If you're writing a novel, SuperNotecard is probably the way to go, as you can create and link to cards for characters, settings, themes, and so on. At just $19 a year, it's ridiculously cheap.

Notebox Disorganizer is one of my favorites. I've written about it before. It's simple but powerful, and best of all, it's free! (Sorry, PC only.)

img

I hope you'll give these programs a try, especially if you're feeling stuck in your writing. Brainstorming, organizing, and then writing can make all the difference. Write down the chaos!


Readers Write

After reading last week's article on listing keyboard shortcuts, macro expert Paul Beverley wrote:

I have a version that spreads the list out a bit and covers more aspects. As you'll see from the attached, it's alphabetic in two ways.
http://www.wordmacrotools.com/macros/K/KeystrokeLister

Thanks to Paul for making this resource available.

Listing Keyboard Shortcuts: Two Methods

By Jack Lyon, the Editorium

As useful as custom keyboard shortcuts may be in using Microsoft Word, it's sometimes difficult to remember which keys you've assigned to what function. Word itself includes one way to find out:

  1. Click File > Print.

  2. Under "Settings," select "Key Assignments: List of your custom shortcut keys":

    img

  3. Select the printer you want to use.

  4. Click the big "Print" button at the top left.

You'll get a document with entries that look something like this:

img

As useful as that might be, it's kind of a mess to read. Microsoft could have done a much better job of formatting.

As an alternative, you can list all of your custom keyboard shortcuts with this handy macro:

Sub ListKeyAssignments() 
Dim kbLoop As KeyBinding
Dim aTemp As template
For Each aTemp In Templates
    If LCase(aTemp.Name) = "Normal.dotm" Then 'You can also use the name of a different template here.
        CustomizationContext = aTemp
        For Each kbLoop In KeyBindings
            selection.InsertAfter kbLoop.Command & vbTab & kbLoop.KeyString & vbCr
            selection.Collapse Direction:=wdCollapseEnd
        Next kbLoop
    End If
Next aTemp
End Sub

You may already know how to add such macros to Word, but if not, here's how.

And you can learn here how to run it.

Now, create a new document and run the macro. You should get results like this in your new document:

img

Much easier to read, don't you think?

After you've created a list of your custom keyboard shortcuts, you can change them or create new ones.

I hope this helps you turn your computer into the lean, mean editing machine it was always meant to be.

Wildcard Secrets Revisited

A few weeks ago I sent out an article called "Three Wildcard Secrets." I thought they were pretty good secrets, too! You can see them here.

In a nutshell, here are the first two:

The wildcard range [A-z], meant to find any uppercase or lowercase letter, will not find accented letters. You have to use [A-Za-z] instead. So I suggested using [!A-z] (not A-z) to find any characters that are accented.

Similarly, if you need to find any unspecified Unicode character, you can use the not range [!^000-^255]. That should work, as 255 is the upper limit on ANSI characters, so anything the range finds must be Unicode.

Then I received a corrective email from macro expert Paul Beverley. The nerve! Here's what Paul had to say about secret #1:

You see the problem? It did what you asked, not what you wanted. It finds any character at all, except A-z.

And Paul is right! The range [!A-z] finds not just accented characters but also spaces, punctuation, and other stuff that isn't letters—something I knew if I'd actually thought about it. You can solve the problem by adding more things that you want to skip. Here's an example:

[!A-z 0-9.,;:\-\?\!^001-^064]

(For more information, see my Wildcard Cookbook for Microsoft Word.)

Next, Paul had this to say about secret #2:

On my PC [!^000-^255] throws up an error:

Now technically, I was right about the range being [!^000-^255]. The problem is that Microsoft Word wants [!^001-^255] instead. And to make things even worse, that wildcard range correctly skips the ASCII characters (numbered 0-126) but incorrectly finds the extended ASCII characters (numbered 127-255), even though we've told it not to. Microsoft strikes again!

But wait, there's more!

  • The range [!^128-^255] gives us the same error message as [!^000-^255].
  • The range [!^127-^255] finds Unicode characters (which it should) and extended ASCII characters (which it should not).
  • The range [!^127-^254] skips extended ASCII characters (which it should) and Unicode characters (which it should not).

All of this weirdness seems to hinge on the points where ASCII becomes extended ASCII, and extended ASCII ends.

Might any of this be useful in your editing work? Yes, if you're using wildcard searches:

  • Use the range [!^127-^255] to find Unicode and extended ASCII characters.
  • Use the range [!^127-^254] to skip Unicode and extended ASCII characters.

That should work, at least until Microsoft decides to fix these problems.

Many thanks to Paul Beverley for his valuable feedback. If you'd like a bunch of free editing macros with instructions on how to use them, you'll want to download Paul's book Macros for Editors.