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 / March 2005

Tip: Looking for answers? Try searching our database.

Why don't disableing screen update work in VBA?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Frank - 26 Feb 2005 13:13 GMT
Why do I experience screen flickering in spite of  disabling the screen update?

The following macro searches through a document and removes redundant table
headings:

Sub TrimRedundantTableHeadings()

Selection.HomeKey Unit:=wdStory
Application.ScreenUpdating = False
Selection.Find.ClearFormatting
With Selection.Find
   .Text = "No table output."
   .Replacement.Text = ""
   .Forward = True
   .Wrap = wdFindStop
   .Format = False
   .MatchCase = False
   .MatchWholeWord = False
   .MatchWildcards = False
   .MatchSoundsLike = False
   .MatchAllWordForms = False
   Do While .Execute
       Selection.TypeBackspace
       Selection.MoveUp Unit:=wdLine, Count:=2, Extend:=wdExtend
       Selection.TypeBackspace
       Selection.MoveUp Unit:=wdLine, Count:=1, Extend:=wdExtend
       If Selection.Text <> "" Then Selection.TypeBackspace
       Selection.TypeBackspace
   Loop
End With
Selection.HomeKey Unit:=wdStory
Application.ScreenUpdating = True
End Sub

Thanks, Frank
Jean-Guy Marcil - 01 Mar 2005 14:39 GMT
Frank was telling us:
Frank nous racontait que :

> Why do I experience screen flickering in spite of  disabling the
> screen update?

Here is the text from the online help:

<quote>
Remarks
The ScreenUpdating property controls most display changes on the monitor
while a procedure is running. When screen updating is turned off, toolbars
remain visible and Word still allows the procedure to display or retrieve
information using status bar prompts, input boxes, dialog boxes, and message
boxes. You can increase the speed of some procedures by keeping screen
updating turned off. You must set the ScreenUpdating property to True when
the procedure finishes or when it stops after an error.
<unquote>

The key words here are "most display changes ".
Basically, and I do not know enough about the display processes in Windows
and/or Word to tell you why, but ScreenUpdating  does speed up execution by
not letting the user see everything the macro does, but if you have a
longish macro that does hundreds of operation (Try your macro on a document
containing 50 pages and many instances of the text to be replaced. Then try
it without ScreenUpdating...), the active window will not only flicker, but
also get "distorted". OTOH, if you do not use ScreenUpdating , then the user
will see everything as Word tries to keep the display up to date with the
macro, which it cannot really. Then you might either hang Word or get a
white window.
An alternative is to make the window (or the application) invisible during
the process. This is even faster, no flickering, but might freak out the
users...

Bottom line is that it is better to use it, especially if you use the
selection object. If you use the Range object instead, you get no flickering
and the ScreenUpdating is not really necessary in most cases (when using a
range object).
Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org 

Howard Kaikow - 01 Mar 2005 15:07 GMT
The bottom line is that in every version of Word I've used, even those with
WordBasic, ScreenUpdating has always had a mind of its own.

Indeed, there appear to be particular actions that will tun on screen
updating even tho you have it set off.

I've given up. I just try to minimize activatioin/opening/closing of
documents, sprinkle a few ScreenUpdating statements hither and yon, and
hope.
Signature

http://www.standards.com/; See Howard Kaikow's web site.

> Frank was telling us:
> Frank nous racontait que :
[quoted text clipped - 34 lines]
> and the ScreenUpdating is not really necessary in most cases (when using a
> range object).

Rate this thread:






 
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.