Hello,
I have a macro that causes Word to hang when the macro is run in a document
that contains comments (the comment "bubbles"). In my macro, I use the
Selection.MoveUntil method and pass in a negative number or the wdBackward
constant. If the current selection is in front of a comment, MoveUntil hangs
word if I try to "back up" over the comment.
Here is a simple macro that shows the problem:
Public Sub GoToPrevStar()
Selection.MoveUntil "*", wdBackward
End Sub
Here is an example of a simple document that can be used to reproduce the
problem:
"The * [insert comment here]quick brown fox"
If I place my cursor after the comment (for example, between quick and
brown) and run the GoToPrevStar macro, Word hangs. If I take out the comment,
the macro works fine.
I have tested this in Word 2003 and Word 2002 and it hangs in both versions.
Has anyone heard of this problem or a workaround?
Thanks,
Mike
Jezebel - 29 Aug 2006 00:06 GMT
Hard to suggest a work-around without knowing what you're actually trying to
do; but in general the answer is: don't use the Selection object. It's never
necessary, and there are always better ways.
> Hello,
>
[quoted text clipped - 28 lines]
> Thanks,
> Mike
MikeT - 29 Aug 2006 00:19 GMT
What I'm trying to do is check to see if the cursor position is between
certain characters. For example, I would like to know if my cursor is between
[ and ].
> Hard to suggest a work-around without knowing what you're actually trying to
> do; but in general the answer is: don't use the Selection object. It's never
[quoted text clipped - 32 lines]
> > Thanks,
> > Mike
Jezebel - 29 Aug 2006 02:03 GMT
You might need to specify this a little more fully: is your condition met if
there is a '[' between the start of document and the cursor, and a ']'
between the cursor and the end of document (ie, regardless of what other
characters might lie in between)?
> What I'm trying to do is check to see if the cursor position is between
> certain characters. For example, I would like to know if my cursor is
[quoted text clipped - 41 lines]
>> > Thanks,
>> > Mike
Tony Jollans - 29 Aug 2006 08:38 GMT
The problem is caused by visible balloons.
The best way to avoid it is to avoid working with the selection. The second
best way, if you don't want to do that, is to make sure there are no visible
balloons either by switching to Normal view (Activedocument.view.Type =
wdNormalview) or switching off balloons
(Activedocument.view.revisionsmode=wdinlinerevisions). In both cases it
would be good manners to restore the user's setting when you're done.
--
Enjoy,
Tony
> Hello,
>
[quoted text clipped - 24 lines]
> Thanks,
> Mike
MikeT - 30 Aug 2006 22:08 GMT
Thanks Tony.
> The problem is caused by visible balloons.
>
[quoted text clipped - 41 lines]
> > Thanks,
> > Mike