+ Reply to Thread
Results 1 to 20 of 20

Controlling Screen flashing using LockWindowUpdate

  1. #1
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Controlling Screen flashing using LockWindowUpdate

    Hi,

    A while back I was assisted with trying to prevent excessive screen flashing...

    I was originally using the Application.ScreenUpdating=False method...but it was still a little jumpy... so Richard Schollar (a valued member in our forum) helped me with this code and it seemed to work...

    Now I am trying to apply it again to another macro and it is not working so well. The thing I found is that on some people's computers it does work well, but not on mine.

    Does anyone know why that is and how I can fix it so it doesn't flash on mine either?

    Please Login or Register  to view this content.
    Thanks for any advice.
    Last edited by NBVC; 12-16-2008 at 09:29 AM.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,997
    Have you tried using SendMessage instead? (No disrespect to Rich but, according to MSDN, that is not really what LockWindowUpdate is for). Something like:
    Please Login or Register  to view this content.
    and of course, set it back to True at the end!

  3. #3
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Hmmm..

    Thanks for the reply.

    It kinda' works but maybe works to the other extreme... I.e. it freezes everything. And unless I click anywhere on my sheet minutes later, it does not automatically refresh my results.

    When I click the button I have to invoke this macro, it doesn't give me the sense or assurance that the button was clicked. I mean I don't even see the button getting depressed and I don't see an hour glass and I don't see anything happen in the status bar. Then it never seems to finish... only when I click some time later, the new info suddenly appears...

    Any way to fix this...

    btw: I took this:
    and of course, set it back to True at the end!
    to mean add this line at the end:

    Please Login or Register  to view this content.
    correct?

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,997
    Yes that's correct. Do you still have the Application.Screenupdating lines in the code? If you turn that off before turning off the redraw, then turn the redraw back on and finally turn screenupdating back on, that ought (I think) to force a screen refresh.

  5. #5
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    The screenupdating didn't really help... still sits there and you don't know when it starts or finishes or what's going on in between.

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,997
    Hmm, it was working ok in my tests, though I should have added that it's probably safer to use 0& and 1& rather than False and True in the API calls. Can you give me some idea what your code does in between and which version of Excel and Windows you are using so I can test appropriately?

  7. #7
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Here's the full code:

    Please Login or Register  to view this content.
    I commented out the LockWindow calls..and replaced them with your SetRedraw calls...

    Basically the code goes through and refreshes several tabs each with a MS Query to our database. Then it creates Pivot Table summaries with additional formulas added in 2 separate summary tabs.

    The previous code would flash between some of the tabs and when it updated the formulas...

  8. #8
    Registered User
    Join Date
    07-02-2008
    Location
    Fort Worth, TX
    Posts
    99
    If its looping thru different tabs, why not add a progress bar userform. I am able to run my progress bar with screenupdating closed by separating it. The code itself updates the progress bar on each loop so that I know that its still running AND when its complete.

  9. #9
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    I didn't really want to complicate the code much... just wanted it to stop jumping around and only show the end result.

  10. #10
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,997
    It seems to work fine using XL2003 on Vista in my tests (better than 2003 on XP was earlier in fact). What setup are you running that is having problems?

  11. #11
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Quote Originally Posted by romperstomper View Post
    It seems to work fine using XL2003 on Vista in my tests (better than 2003 on XP was earlier in fact). What setup are you running that is having problems?
    Not sure what you mean by "What setup am I running?"

  12. #12
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,997
    Sorry I just meant which version (and service pack) of windows and office are you running?

  13. #13
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    I am running XP Profession Ver. 2002 SP2 and Excel 2003 SP2.

    I tried it all again this morning and it just doesn't give the sense that it is doing anything... Only when I clicked on another application and returned to Excel, was I able to navigate around Excel...

  14. #14
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,997
    As a matter of interest, does this work?
    Please Login or Register  to view this content.

  15. #15
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Well, that seems to work a lot better... I'll keep testing it.

    I did try fixing it according to your previous post
    Hmm, it was working ok in my tests, though I should have added that it's probably safer to use 0& and 1& rather than False and True in the API calls. Can you give me some idea what your code does in between and which version of Excel and Windows you are using so I can test appropriately?
    but I guess I replaced the wrong things...

    Thanks alot for your assistance... Now I need to figure out a way to get this thing to process faster...

    Thanks again Romperstomper,

    NBVC

  16. #16
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,997
    No worries. You might want to look at BorderAround instead of setting all those borders individually and there are a couple of external routines that you call which may be bottlenecks, but other than that I can't see much obvious to speed it up, short of maybe replacing the querytables with ADO and reusing a connection if all the data comes from the same place.

  17. #17
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Thanks again for the advice...

    I will definitely look into those options.


    NBVC

  18. #18
    Registered User
    Join Date
    05-02-2007
    Location
    US
    MS-Off Ver
    2000 @work, 2003 @home
    Posts
    23
    I'm not trying to step on any toes here on a solved thread. Or anyone elses help. But felt the need since it was mentioned. This is something that I use on mine. I am still a total noob to vba, but I was wondering if this would help you NBVC?
    Replacing this part:
    Please Login or Register  to view this content.
    with this:
    Please Login or Register  to view this content.
    or maybe this would work for you, it would help with the elimination of selecting, since from your code the range seems fixed at this time:
    Please Login or Register  to view this content.
    Of course, change it however it suits you. Or ignore it.
    I had gotten tired of having such big codes myself, and managed to just eliminate alot of the lines by simply removing "(name of border)". I don't know if there is a reason for why this isn't used as much, maybe there is something wrong with it? Feed back is welcome on this.
    I just saw the opportunity to maybe help out a little. If it does, great.

    David
    note: I am still wet behind my ears on Excel and helping others as well with it
    Last edited by dcraker; 12-16-2008 at 06:56 PM. Reason: mentioning of solved thread

  19. #19
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    dcraker,

    I did try your code and it worked great.

    Thank you.

    I am not sure it made the code run much faster, but it does look a lot cleaner.

  20. #20
    Registered User
    Join Date
    05-02-2007
    Location
    US
    MS-Off Ver
    2000 @work, 2003 @home
    Posts
    23
    I'm glad that it worked for you. And thanks for letting me know.
    Thanks,
    David
    yes, there is only one c

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1