![]() |
#1
|
|||
|
|||
![]()
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 |
Tags |
comment, moveuntil, word hangs |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Word hangs completely when editing punctuation | cydevil | Word | 4 | 11-24-2016 04:16 PM |
![]() |
pintree3 | Office | 5 | 04-14-2014 02:27 PM |
![]() |
KevinJ | Word VBA | 2 | 11-05-2012 01:27 PM |
![]() |
pstein | Word | 2 | 03-31-2012 05:31 AM |
Hyperlink Look In Hangs Word 2010 | drumms | Word | 0 | 02-24-2012 11:35 AM |