Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / August 2006

Tip: Looking for answers? Try searching our database.

MoveUntil method hangs

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
MikeT - 28 Aug 2006 22:54 GMT
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

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.