Hiding the cursor in Word through VBA?

J

Jean Ryckebosch

Hi,

Is there a way to hide the textcursor in Word? I need to hide the textcursor
while doing some lengthy operations.

Thanks in advance

Jean
 
J

Jean Ryckebosch

With the cursor I mean the blinking textcursor. It would be really great, if
you could make the textcursor disappear as long as you don't click on the
document.
So, just make it hidden on the current location...(if the word document
loses focus, then the textcursor disappears, this is exactly what I want.)
 
H

Helmut Weber

Hi Jean,
usually
Application.ScreenUpdating = False
should be sufficient.
Or are there special complications?
 
J

Jean Ryckebosch

Hi Helmut,

Thank you for your answer. Unfortunately, there are complications...

Here is what should be happening. Suppose you have a normal Word document. I
want to highlight every word in the document (one after the other, e.g.
every second) by changing the text color. I managed to make this work. So
every second, the next word is highlighted. However, I have a problem with
scrolling. If I highlight a word that is no longer visible for the user, I
should scroll. I tried to use ActiveDocument.ScrollIntoView myRange but this
causes trouble with the textcursor. It jumps back and forth between my
highlighted word and the textcursor (which is not a pretty sight). The
solution would be to move the textcursor along with the highlighted word. I
can make this work (and it scrolls automatically then) but the problem is
that the textcursor is visually very distracting. I'm under the impression
that Application.screenupdating isn't hiding the textcursor. It's still
there, blinking and all.

Any ideas?
 
J

Jonathan West

Jean Ryckebosch said:
Hi Helmut,

Thank you for your answer. Unfortunately, there are complications...

Here is what should be happening. Suppose you have a normal Word document.
I
want to highlight every word in the document (one after the other, e.g.
every second) by changing the text color. I managed to make this work. So
every second, the next word is highlighted. However, I have a problem with
scrolling. If I highlight a word that is no longer visible for the user, I
should scroll. I tried to use ActiveDocument.ScrollIntoView myRange but
this
causes trouble with the textcursor. It jumps back and forth between my
highlighted word and the textcursor (which is not a pretty sight). The
solution would be to move the textcursor along with the highlighted word.
I
can make this work (and it scrolls automatically then) but the problem is
that the textcursor is visually very distracting. I'm under the impression
that Application.screenupdating isn't hiding the textcursor. It's still
there, blinking and all.

Any ideas?

How exactly are you applying the new color to each word? This might be the
key to why the window keeps scrolling back & forth. Could you show us the
code for the relevant loop in your program?
 
H

Helmut Weber

Hi,
workaraounds:
scroll the cursor out of view,
reduce the size of the cursor to 1 point,
set the blinking interval to a very high value,
API SetCaretBlinkTime,
api-functions that seem to be appropriate
could be hidecaret, or destroycaret or showcursor,
but i couldn't get it to work. I guess, if the macro
hands the control back to word, the cursor will
be restored anyway. And I got only very short macros
here for testing. For the longer taking macros,
I minimize the application window anyway.
 
J

Jean Ryckebosch

Hi Jonathan and Helmut,

Your answer triggered me to give it another go with the ScrollIntoView. I
thought this only worked for as long as the textcursor was visible.
Apparently, I was wrong.
I used to do things differently for highlighting words. With the changed
procedure, it now seems to work perfectly well if I use ScrollIntoView.
Thanks a bunch for your answers...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top