Macro loops if break point is set

T

Top Spin

I wrote the little macro showb below to increase the paragraph
"spacing before" setting by 6 points.

It works just fine unless I set a break point (F9). Then it loops
forever. If I step through it (F8) or turn it loose (F5), it goes
right back to the Sub statement and runs over and over.

What am I doing wrong?

Thanks

Here's the macro code:


Sub IncLineSpaceBef6pts()
Dim setting As Single, reply As Long, msg As String

setting = Selection.ParagraphFormat.SpaceBefore

If setting < 999 Then 'If the selection is all the same setting,
'increase it by 6
Selection.ParagraphFormat.SpaceBefore = setting + 6
Else 'Otherwise, ask for instructions
msg = "The selection contains multiple Space Before settings. " _
& "Set them all to 6?"
reply = MsgBox(msg, vbYesNoCancel + vbDefaultButton2,
"SpaceBeforeToggle macro")
If reply = vbYes Then 'If they say yes, set them all to 6
Selection.ParagraphFormat.SpaceBefore = 6
End If 'Otherwise, do nothing
End If

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top