Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Textbox refresh

Status
Not open for further replies.

engdernw

Programmer
Nov 4, 2011
9
CA
I am running a macro in Word, doing in the background many modifications to the opened document. At the same time, the macro is updating a textbox displayed in the foreground window, to show all modifications done. This textbox acts a bit like a "progress window" when installing a new application (you may sometimes display the list of files that are being installed).

To send new information to the textbox, I am using the method
Textbox.value = Textbox.value & newtext

with newtext being a public string of characters to add.

I also add the line
Progression.TextBox1.SelStart = Len(Progression.TextBox1.Text)
to force the textbox to scroll to the end and hopefully refresh its display.

The problem that I have is that the textbox doesn't always refresh properly, or should I say, I know it is refreshing, but it actually "hangs" as if it was not responding and new text doesn't show up. It is only when the macro is done that all text displays properly and that I can check the textbox has been updated as it should have.

I have the feeling that this happens when the textbox receives lots of updates in a short period of time.
I tried to use the Repaint function, with no luck.
Any suggestion?
 

Can you do:
Code:
Textbox.value = Textbox.value & newtext[blue]
Textbox.Refresh[/blue]
?

Have fun.

---- Andy
 
I already tried, but this doesn't seem to exist. I have an error message saying "Method or data member not found", pointing to .Refresh...
 
I almost never program in Word, but would a "DoEvents" help?

If, as you say, you have other things going on as well, there might simply be some contention, which DoEvents could relieve.

Tony
 
Well, I just added a DoEvents, as someone else in another forum pointed this too! Great minds, you rock Tony!
It seems to be working indeed! :)
I still need to force the textbox to scroll down, though, when I am adding text. The current line
Progression.TextBox1.SelStart = Len(Progression.TextBox1.Text)
is not doing it...
 
I updated the last line to
Progression.TextBox1.SelStart = Len(Progression.TextBox1.Value)
and everything is working as it should now...

Thanks all for your help! :)
 

If Progression is the name of your Form, you may also try:
[tt]
Progression.TextBox1.SelStart = Len(Progression.TextBox1.Value)
Progression.Refresh
[/tt]
Just for kicks and giggles....

Have fun.

---- Andy
 
Ha, that's an interesting one! Will definitely give it a try, though DoEvents works perfectly as well!
Thanks Andy! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top