I will now return to less brain-hurting stuff in the next few posts, because I am currently in pursuit of bushrangers, rocks and crash remedies and all my hurt brain facilities are overloaded.
Creating a macroA macro is simply a collection of recorded key strokes that can be run again, using a shortcut. These are created in a form of Visual Basic that looks quite worrying if you try editing a macro, so don't bother (yet), just be aware that you can create and record complicated sequences without knowing anything at all about how they are coded.
Macro ideasThe first thing to be said is that it is hard to keep track of the macros and what they are called. It is also important to know that some of the special key commands like Control-C, Control-V, and Control-X, (copy, paste and cut highlighted text, respectively) are valuable. Word is set up with those (effective) macros ready to run, and you need to experiment to see if you need Control-I, Control-B, or Control-U, which convert highlighted text to italics, bold and underline.
Paste unformatted text, PasteUnformattedCtrlU-my only failureFrom time to time, you will get text such as HTML or fields and if you insert a table of contents into a document, the table is not real text, which can be a nuisance in some cases. The same thing applies if you are using Excel, and later want to paste material into Word: if you hit Edit-Paste Special-Unformatted text, you can avoid this, but I have never yet been able to make a macro to do this. If any reader succeeds, please tell me how you did it!
DegreeSymbolCtrlShftDAs mentioned above, this character is something I need all the time, so I have a macro to do it. All the macro does is produce the appropriate degree character ° (of course, if you hold down the Alt key and type 0176 on the numeric pad, that does the same thing).
Multiple operationsThere are times when I need to do the same thing, many times over: it may be as simple as finding all the carriage returns that are Heading 4 and converting them to Heading 3. You can do that with a simple replace command, but suppose you want to autonumber the header paragraphs (using Insert - Field - Autonum): in that case, you need a macro. First, you search for the next instance of Heading 4, change the paragraph to Heading 3, hit Home to get to the start of the line, and then insert the field.
Jumping in and out of ExcelCall me weird if you will, but I have written a whole book in Excel. Not on Excel, but in Excel. There was a reason for doing this: it was an illustrated children's book on reef life, and I needed to offer species lists for each page for the artist. Once I had created a record on a single line for a fish that was on page 5, complete with references to where the artist would find models or photos, I could make extra copies of that line and assign one of the lines to page 9, and another to page 14, where the same fish was also to appear. Other lines had the text for the page, and so on.
.Text = "\enfm"
.Replacement.Text = "female explorers, "
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
"# .Forward = True# .Wrap = wdFindContinue# .Format = False# .MatchCase = False# .MatchWholeWord = False# .MatchWildcards = False# .MatchSoundsLike = False# .MatchAllWordForms = False#End With#Selection.Find.Execute Replace:=wdReplaceAll
Running the keywords macroWe aren't finished yet: we need to run the macros in order, but I often forget where I am at, so I have created a super macro, KeywordsAllCtrlShL, which simply runs the four conversion macros. Then having pasted the spreadsheet column over and having run the macro, each paragraph ends in a comma and a space.
AcknowledgementsMy thanks to Bryn Jones who reminded me to mention the use of abbreviations that are converted by Autocorrect.
The other bits