Word VBA >> Setting break point (F9) causes macro to loop forever

by Top Spin » Wed, 04 Aug 2004 13:42:15 GMT

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


Word VBA >> Setting break point (F9) causes macro to loop forever

by Jezebel » Wed, 04 Aug 2004 14:34:00 GMT


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










Word VBA >> Setting break point (F9) causes macro to loop forever

by Top Spin » Wed, 04 Aug 2004 16:49:09 GMT

On Wed, 4 Aug 2004 16:34:00 +1000, "Jezebel" < XXXX@XXXXX.COM >



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


Setting break point (F9) causes macro to loop forever

by Gerry Knight » Sun, 08 Aug 2004 13:59:54 GMT

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.







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


Similar Threads

1. Macro loops if break point is set

2. VB.NET can't set break point

3. Array set only with break points - Visual Basic/VB

4. Break Point not set, no errors, app enteres debug mode at Previous

I have an application that breaks into debug mode on a previously set Break 
Point, even after having closed and re-opening the application.

It acts as if the break point is still set.

This problem occurs after setting a Break Point and then removing the Break 
Point.

What can I do to stop the application stopping at previously set Break Point.

The vba code is in an Access form.
-- 
Regards John

5. CTRL-A F9 causes contents of file to be shaded like a field - Word Document management

6. CTRL-A F9 causes contents of file to be shaded like a field

On May 12, 8:19 am, "yoshi.mitsou" < XXXX@XXXXX.COM > wrote:
> If I select all and hit f9 to update the document, the entire file
> becomes shaded like it's a field. If I turn off field shading then the
> shading disappears.
>
> This happens in Word 2007 or Word 2003 with compatibility mode in
> Windows XP.  I'm at a loss. Does anyone have any suggestions?

Of course, I figure this out after I post. Sorry. It has something to
do with cross references--when I remove a section with  several cross
references, this problem disappears. I think the x-refs were added to
show all text instead of just the label/number. Thanks.

7. Breaking a for loop and nested for loop????

8. Next pg sec break doesn't work, but even pg sec break causes probl

I have a 100+ page document with odd/even page headers divided into multiple 
sections by next page section breaks.  My supervisor doesn't want any 
whitespace at all, so I've been using styles and a bit of fiddling in the 
paragraph window ("keep with next") to avoid it.  Umm... also, I've been 
de-"link to previous"ing many of the h/f sections.
Now, as far as I can tell, when the section break is at or near where the 
page break would've been anyway - though not always - the next page section 
break causes a page of whitespace between the two sections.  However, when I 
change the next page section break to an even page section break, the page 
numbering skips a number - starting at 1-2, instead of 1-1 (the first number 
is part of the field, and not a manual edit).
Is there any way I can get rid of the blank page and keep correct page 
numbers at the same time?