This is an old revision of the document!
Generally, I don't mess with formatting while translating text, but while I'm reviewing the translation, I cannot help but notice occasional—and sometimes not-so-occasional—formatting that cries out for a paragraph to have some space added either before or after.
The VBA code to do this is actually pretty straightforward. Here's the code for the macro
IncreaseAfterBy3 (deducing what the code might be for a macro named
IncreaseBeforeBy3 is left as an exercise for the reader):
Sub IncreaseAfterBy3() ' ' Increase the space after the current paragraph by 3 points ' ' With Selection.ParagraphFormat .SpaceAfter = .SpaceAfter + 3 .SpaceBeforeAuto = False .SpaceAfterAuto = False End With End Sub
I do not know whether setting both
.SpaceAfterAuto to false is absolutely required for this macro to work correctly, but as they do no harm in any event, I've left them in.
I've use this macro quite often, and in one section of this one document I was reviewing/editing, I noticed that it didn't seem to work at all. Puzzled, I brought up the
Paragraph dialog box and noticed immediately that (a) the box labeled
Don't add space between paragraphs of the same style was checked, and that (b) the specified spacing after the paragraph in question was now rather large, as I had executed the macro multiple times.
It occurred to me that since I wanted to increase the spacing after the paragraph, the solution was to have the macro uncheck the
Don't add space… box, and the most direct method I could imagine of doing this was to fire up Word's
Record Macro capability and step through the process, during which I would check the box, and then copy the line(s) that did what I wanted into the macro.
Surprisingly, the resulting VBA code didn't provide any clues as to what those lines might be, so I recorded a second macro that basically did the same thing, except this time, I unchecked the box. I figured if any lines changed in the generated code, that those were the lines I needed.
As it turned out the code for both operations was identical.
Back to the drawing board!
After a few minutes with Google, I determined that property I was interested in was associated with a
Style and not a
Paragraph, as in the line:
ActiveDocument.Styles("Normal").NoSpaceBetweenParagraphsOfSameStyle = False
The main hangup with this one-liner is that it applies to the
Normal; using this approach would change the parameter for all paragraphs in the document whose style was
Normal. What I wanted was a way of changing this property just for the paragraph in which the cursor was located. After a bit more digging, it turned out the following code does the trick:
With Dialogs(wdDialogFormatParagraph) .NoSpaceBetweenParagraphsOfSameStyle = 1 .Execute End With
Inserting these lines just before the
End Sub line in the
IncreaseAfterBy3 macro code gains the desired behavior. Now, whenever I want to open up just a bit of space beneath a paragraph, that space will appear.