+ Reply to Thread
Results 1 to 8 of 8

Application.screenupdating fail

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    06-15-2007
    Location
    Scotland
    Posts
    142

    Application.screenupdating fail

    HI
    I have a workbook which has a code with the following structure:

    Private Sub Workbook_Open()
    Subname1
    End sub
    
    The structure of each sub is 
    
    Sub subname1()
        Application.DisplayAlerts = False
        Application.ScreenUpdating = False	
    Code that open and close several files to copy and paste data from that files into the workbook
        Application.DisplayAlerts = true
        Application.ScreenUpdating = true
    End Sub
    Even using the application screenupdating I can see how the subname1 goes and open go to the sheets and close files to copy and paste.

    Any idea why this is happening?. I used in the past the property to copy and paste data from one sheet to another and worked fine, so I am not sure why this time is not working, the difference this time is that I am using external data from other workbooks

    Best regards

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,525
    I don't know if this will help, but maybe placing the screen updating code in the module that calls the macro IE:
    Private Sub Workbook_Open()
    application.screenupdating=false
    Subname1
    application.screenupdating=true
    End sub

  3. #3
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good afternoon mmf

    Does your code use SendKeys?
    If so, then the Application.ScreenUpdating construct is ineffective against this command.

    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  4. #4
    Forum Contributor
    Join Date
    06-15-2007
    Location
    Scotland
    Posts
    142
    DaveExcel
    I sused that one but still the same, I still see how the applciation just flash from one screen to another.

    Dominicb, What does sendkey means?
    I am just using very simple code to open and close workbooks with activate select copy and pasting commands in between

    Cheers

  5. #5
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770
    Quote Originally Posted by mmf View Post
    DaveExcel
    I am just using very simple code to open and close workbooks with activate select copy and pasting commands in between
    Activate & Select are causing your problems here. As far as I know using either of them will switch screenupdating back to true, (as both Activate, and 'Select' are visual functions, so therefore HAVE to update the screen).

    You need to recode your copy & paste routines to not use the select or activate functions.

  6. #6
    Forum Contributor
    Join Date
    07-01-2008
    Location
    Cincinnati, OH
    Posts
    150
    Sometimes this construct works where App.ScreenUpdating fails.

    Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long
    Private Declare Function GetDesktopWindow Lib "user32" () As Long
    
    Sub SomeSub()
    
        On Error GoTo Err_SomeSub
        
        LockWindowUpdate GetDesktopWindow
        
        'your code
    
        LockWindowUpdate 0
        
    Exit Sub
    Err_SomeSub:
        LockWindowUpdate 0
        
    End Sub

  7. #7
    Forum Contributor
    Join Date
    06-15-2007
    Location
    Scotland
    Posts
    142
    thnaks for the suggestion, I did what you wrote, and works for one of the sub, however for another ones I still having the blinks,
    best regards

  8. #8
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,525
    Quote Originally Posted by mmf View Post
    thnaks for the suggestion, I did what you wrote, and works for one of the sub, however for another ones I still having the blinks,
    best regards
    If you have selects in your code the blinks may be inevitable.
    Whats the code look like?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Renaming Spreadsheet causes macros to fail
    By AdamParker in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-11-2008, 11:45 AM
  2. List with missing links!!!
    By Sirishgreen in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 11-01-2007, 09:25 AM
  3. How can I fail based on an exception?
    By geezerman402 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-18-2007, 06:25 PM
  4. Reviewing Toolbar - past results fail
    By The Muffin Man in forum Excel General
    Replies: 0
    Last Post: 04-25-2007, 11:46 AM
  5. calcule target value and % based on increased volume
    By diskette in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-22-2007, 12:18 PM

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