In prior posts, I talked about how effective online editing includes mastering macros. See, for example, The Professional Editor: Working Effectively Online IV — Mastering Macros. What wasn’t discussed is how to plan a macro.
For the simple macro, the macro that, for example, replaces two spaces with one space, not much planning is required; what is needed is fairly obvious. As a macro grows more complex, however, the difference between success and failure is often how much effort was placed in the planning of the macro. A well-planned macro nearly writes itself.
Consider most of the macros in the EditTools collection. These are complex macros that require multiple routines to accomplish designated goals and tasks. Because of their complexity, it is easy to get lost in the programming and thus not produce a usable macro.
Consequently, when planning a macro I use a decision-tree process. I also use Storyboard paper that I buy from Levenger because it helps me visualize what I need to do. More importantly, it breaks what I need to do down into manageable chunks.
I begin at the end of the process: I define what I want the macro to accomplish. I then try to define each step that will take me to that endpoint. I use the If…Then… process: If abc is found, Then do xyz, but If abc is not found, Then do pqr.
Using the storyboard, I make each If…Then… its own entry. In the blank box on the left, I write the If…Then…; on the lines to the right, I write the code, line by line to make the If…Then… happen. It takes at least a pair of boxes to make a single whole If…Then… phrase because the first is the found and the second is the not found. Sometimes more than one not found is required so a single If…Then… process may need more than a pair of boxes.
Note, however, that I am using the If…Then… concept as a substitute for a lot of possibilities. It should not be taken literally as an If…Then… in coding terms. It is simply a way of breaking the process down into manageable chunks.
Making these small blocks of code serves many purposes. To make them reusable, I also number them. The numbers are not used except as a way to cross-reference. If I have already written a chunk of code that will do what I need done in the next step, I simply refer to the block of code by number for later copy and paste.
The small chunks also serve a much more important purpose: they make it easier to figure out why something is not occurring as I intend. Plus they can be reused in other future macros — no sense reinventing the macro. And they make it much easier to rearrange a macro’s coding when I subsequently think of a better or more efficient way to accomplish a task.
Yet I can hear the question now: Why do on paper what you need to do online? Yes, it can be repetitive work to first do the coding on paper and then transfer the coding to online, but the process allows me to think twice about what I am doing and — definitely of more importance — coding online takes away the storyboard decision-making tree, thus making it harder to visualize the entire process or even how a small portion fits within the scheme of the macro. A little extra work now often saves a lot of extra work later.
If you look at the Storyboard paper, you see the box at the left in which I place my decision-tree information. That information serves much the same purpose as inserting a comment into a macro. But on the Storyboard I can readily see what comes before and what comes after the block on which I am working, which can be difficult to do onscreen.
No matter what method you ultimately choose, you need to have a decision-tree method at hand so as to avoid missing important steps in the macro process or leaving out things you want the macro to do depending on what is found or not found. If you use or have available Microsoft PowerPoint (or a similar program), you can use it to create an onscreen storyboard. I have tried it, but found it too cumbersome for me; at heart, for these kinds of tasks, I’m still a creature of habit and my generation and paper and pencil seem to work best.
The key is, however, to plan your macro. Even if the coding is beyond your capabilities and so you intend to hire someone to code the macro for you, having a decision tree that can be given to the coder will reduce your costs and ensure that the coder understands what you want. The coder may have suggestions for improvement, but the decision tree ensures that everyone is on the same page.
The decision tree can also make your learning to code complex macros easier and quicker. Combine it with Jack Lyon’s Macro Cookbook for Microsoft Word, and you will discover that as you learn to code a small portion of a macro you are mastering macros. You will also find a greater sense of accomplishment as one coding success follows another in logical sequence.
The combination of the decision-tree process and the Macro Cookbook is a sure way to master the macro process a professional editor needs. Remember that the more efficiently you can edit the more money you can make over the long-term. The biggest failing professional editors have is the inability to get beyond the short-term outlook. Taking on the challenge of mastering macros will help you extend your outlook to the longer term.