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 / July 2007

Tip: Looking for answers? Try searching our database.

TypeText returns before completing

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jamie.fallon@gmail.com - 02 Jul 2007 17:10 GMT
Does TypeText return before completing?

I have a long macro that does loops. In the loop, it does a find, and
then uses TypeText to replace the found string, and then does a few
MoveDown's and deletes some stuff. If I step through the code line by
line it works fine, but when I run the macro, it seems to do the
delete before typeText is finished. I might have solved the issue by
putting a delay after the TypeText so that word can "catch up" to the
typing. But this seems like a bad solution. Can anyone answer the
above question about TypeText?
jamie.fallon@gmail.com - 02 Jul 2007 19:17 GMT
I found some suggestions in other threads. One person suggested
putting word into Normal view, and turning off auto-pagination. That
does seem to help. It lets the macro run faster.

Another person reccommended using Range instead of things like
Select.TypeText. I'm pretty sure that Selection.Typetext is
ascynchronous. Can anyone verify that Range commands are synchronous
(won't return until the change is made)?
Jay Freedman - 02 Jul 2007 20:10 GMT
> I found some suggestions in other threads. One person suggested
> putting word into Normal view, and turning off auto-pagination. That
[quoted text clipped - 4 lines]
> ascynchronous. Can anyone verify that Range commands are synchronous
> (won't return until the change is made)?

It's not that Range commands are synchronous, but they're orders of
magnitude faster than Selection.TypeText, especially if screen redrawing
hasn't been turned off. Assigning

   myRange.Text = someStringValue

is nearly instantaneous, even if the string is very long.

Signature

Regards,
Jay Freedman
Microsoft Word MVP        FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

jamie.fallon@gmail.com - 02 Jul 2007 21:48 GMT
> jamie.fal...@gmail.com wrote:
> > I found some suggestions in other threads. One person suggested
[quoted text clipped - 20 lines]
> Email cannot be acknowledged; please post all follow-ups to the newsgroup so
> all may benefit.

Gotcha. Thank you. Am I likely to be ok with Selection.TypeText if I
require background repagination to be turned off? In the future I'll
avoid using Selection.TypeText in a loop.

-Jamie
Klaus Linke - 03 Jul 2007 00:00 GMT
> Am I likely to be ok with Selection.TypeText if I
> require background repagination to be turned off?

Hi Jamie,

Another problem with .TypeText is that it's limited to 64kB (about 32000
characters).
If your strings might be longer, you'd need to replace it with
Selection.InsertAfter -- followed by Selection.Collapse(wdCollapseEnd) if
necessary.

Regards,
Klaus
 
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.