Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 11-12-2017, 12:14 PM
gunner359 gunner359 is offline Word hangs when MoveUntil is used and Comment present Windows 10 Word hangs when MoveUntil is used and Comment present Office 2016
Novice
Word hangs when MoveUntil is used and Comment present
 
Join Date: Oct 2017
Posts: 6
gunner359 is on a distinguished road
Question Word hangs when MoveUntil is used and Comment present

Hi All,

Summary: MoveUntil VBA command hangs Word 2016 when a Comment is
within range of a negative or wdBackward Count parameter. MoveEndUntil and
MoveStartUntil also fail. Further testing indicates that setting Count positive
or wdForward works. See details below.

First time poster. Platform is Windows 10 and Office 2016. My customer has a
slew of Word documents that they pass around and edit. They wanted a macro
that allows them to insert text strings into the document that are highlighted
white text on a green background and hidden. Easy enough. I have the user type
a + sign followed by the string. The macro is invoked by the keyboard shortcut
Alt-m; the string from the insertion point (IP) back to the + sign is given a
style I created and the + sign removed. All is working great.

In my macro, I use the VBA commands:

Dim i As Long


...
i = Selection.MoveUntil(Cset:="+", Count:=wdBackward)

to find the + sign and the length of the string (-i-1). Works very well.
When the + sign is missing, the MoveUntil command returns 0 and the
macro is conditioned to handle this case.

But here is the rub. When the user
inserts a Comment in the document and types Alt-m prior to the
Comment, the MoveUntil command returns 0. Good. When the IP is after
the Comment and Alt-m is typed, Word VBA stops on the VBA command

i = Selection.MoveUntil(Cset:="+", Count:=wdBackward)

and the cursor spins looking like a wheel. No error, no nothing.

When I change the Count to -100:

i = Selection.MoveUntil(Cset:="+", Count:=-100)

all works well when Alt-m is typed and the IP is > 100 characters after
the Comment. When the IP is between the Comment and the 100th
character after the Comment, the MoveUntil command hangs
and Word hangs (Not Responding). Word has to be
restarted. Sounds like MoveUntil is confused when it runs into a
Comment. Any ideas? I'm trying not to use Find as the setup a little
tedious and Find would take much longer that MoveUntil (I think).

Any help would be appreciated. Thank you.

Last edited by gunner359; 11-12-2017 at 09:28 PM. Reason: Further testing
Reply With Quote
 

Tags
comment, moveuntil, word hangs



Similar Threads
Thread Thread Starter Forum Replies Last Post
Word hangs completely when editing punctuation cydevil Word 4 11-24-2016 04:16 PM
Word hangs when MoveUntil is used and Comment present How to make Office (Word) 2010 stick to the present task pintree3 Office 5 04-14-2014 02:27 PM
Word hangs when MoveUntil is used and Comment present VBA equivalent to selecting present word KevinJ Word VBA 2 11-05-2012 01:27 PM
Word hangs when MoveUntil is used and Comment present How to insert a (balloon) comment and how to disable comment feature in Word2007? pstein Word 2 03-31-2012 05:31 AM
Hyperlink Look In Hangs Word 2010 drumms Word 0 02-24-2012 11:35 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:14 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft