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

It works just fine unless I set a break point (F9) anywhere in the
macro. 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


--
For email, use Usenet-20031220 at spamex.com

Re: Setting break point (F9) causes macro to loop forever by Jezebel

Jezebel
Wed Aug 04 01:34:00 CDT 2004

There's nothing obviously wrong in the code (not obvious to me, anyway).
What actually triggers the macro in the first place?



"Top Spin" <ToppSpin@hotmail.com> wrote in message
news:6mt0h0l9v20dcqj8c929pjgoncr8oflsnv@4ax.com...
> I wrote the little macro shown below to increase the paragraph
> "spacing before" setting by 6 points.
>
> It works just fine unless I set a break point (F9) anywhere in the
> macro. 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
>
>
> --
> For email, use Usenet-20031220 at spamex.com



Re: Setting break point (F9) causes macro to loop forever by Top

Top
Wed Aug 04 03:49:09 CDT 2004

On Wed, 4 Aug 2004 16:34:00 +1000, "Jezebel" <dwarves@heaven.com.kr>
wrote:

>There's nothing obviously wrong in the code (not obvious to me, anyway).
>What actually triggers the macro in the first place?

I have it assigned to a keyboard shortcut (Ctrl+{).

I open the VBA editor, set uop a break point (F9), hot key back to
Word, select some text, and type the Crtl+{.

The macro starts right up and will execute correctly. But when I
reached the last line, it loops back and starts again.

I also noticed that the "Reset" button on the VBA Editor toolbar (the
little blue square that stop execution) is never greyed out. In VB6,
it is only blue when a some VB code is running. This one is blue all
the time.

--
For email, use Usenet-20031220 at spamex.com

Re: Setting break point (F9) causes macro to loop forever by Gerry

Gerry
Sun Aug 08 00:59:54 CDT 2004

Do not run the code from Word for testing. If you want to use
breakpoints, run the code from the VBE. When you execute from Word
itself, it has no idea what to do with breakpoints. When code is compiled
for run-time (as it would be, called from Word) those breakpoints are
ignored. However, you have the VBE open, so it kinda tries. Select your
text in Word, go back to the VBE and run your code.

On Wed, 04 Aug 2004 01:49:09 -0700, Top Spin <ToppSpin@hotmail.com> wrote:

> On Wed, 4 Aug 2004 16:34:00 +1000, "Jezebel" <dwarves@heaven.com.kr>
> wrote:
>
>> There's nothing obviously wrong in the code (not obvious to me, anyway).
>> What actually triggers the macro in the first place?
>
> I have it assigned to a keyboard shortcut (Ctrl+{).
>
> I open the VBA editor, set uop a break point (F9), hot key back to
> Word, select some text, and type the Crtl+{.
>
> The macro starts right up and will execute correctly. But when I
> reached the last line, it loops back and starts again.
>
> I also noticed that the "Reset" button on the VBA Editor toolbar (the
> little blue square that stop execution) is never greyed out. In VB6,
> it is only blue when a some VB code is running. This one is blue all
> the time.
>



--
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/