+ Reply to Thread
Results 1 to 10 of 10

Opening Excel Workbook [takes too long with Workbook_Open]

  1. #1
    Forum Contributor
    Join Date
    07-07-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    500

    Opening Excel Workbook [takes too long with Workbook_Open]

    Greetings,

    I have the following code that is set for Workbook Open. However the opening process takes as long as 30 seconds to open. Is it my code not correct?
    Please Login or Register  to view this content.
    Last edited by 6StringJazzer; 05-30-2018 at 12:48 PM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,696

    Re: Opening Excel Workbook [takes too long with Workbook_Open]

    How many worksheets are there?

    ETA: I tried this on a file with five sheets and it took under 2 seconds.

    start 5/30/2018 12:53:38 PM
    screen off 5/30/2018 12:53:38 PM
    Sheet1 5/30/2018 12:53:38 PM
    Sheet2 5/30/2018 12:53:38 PM
    Sheet3 5/30/2018 12:53:39 PM
    Sheet4 5/30/2018 12:53:39 PM
    Sheet5 5/30/2018 12:53:39 PM
    min ribbon 5/30/2018 12:53:39 PM
    1 5/30/2018 12:53:39 PM
    screen on 5/30/2018 12:53:39 PM
    Last edited by 6StringJazzer; 05-30-2018 at 12:54 PM.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Contributor
    Join Date
    07-07-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    500

    Re: Opening Excel Workbook [takes too long with Workbook_Open]

    The workbook has 44 worksheets. However, I only have 1 open when starting up.

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,696

    Re: Opening Excel Workbook [takes too long with Workbook_Open]

    What do you mean by "open"? Do you mean visible? Your code touches every worksheet, whether or not it's visible. That is probably what is taking the time.

  5. #5
    Forum Contributor
    Join Date
    07-07-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    500

    Re: Opening Excel Workbook [takes too long with Workbook_Open]

    Yes, when visible. The code is to allow for macros to be run on protected worksheets. Should I use code for each worksheet? If so, what would the code be?
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    07-07-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    500

    Re: Opening Excel Workbook [takes too long with Workbook_Open]

    I found the following code and inserted it into the worksheet code. I also disabled the code for the workbook and all seems to be running much faster.
    Please Login or Register  to view this content.

  7. #7
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,696

    Re: Opening Excel Workbook [takes too long with Workbook_Open]

    How is the new worksheet code is being called? I suspect it is not, which is why it would run faster.

    I would do this in your workbook module:
    Please Login or Register  to view this content.
    Last edited by 6StringJazzer; 05-30-2018 at 04:21 PM. Reason: removed errant space from xlSheet Visible

  8. #8
    Forum Contributor
    Join Date
    07-07-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    500

    Re: Opening Excel Workbook [takes too long with Workbook_Open]

    StringJazzer,
    That works perfect!
    I changed the third line
    Please Login or Register  to view this content.

  9. #9
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,696

    Re: Opening Excel Workbook [takes too long with Workbook_Open]

    Oh, sorry, my bad typing.

  10. #10
    Forum Contributor
    Join Date
    07-07-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    500

    Re: Opening Excel Workbook [takes too long with Workbook_Open]

    No worries!
    I have another issue. I want to protect the Workbook, but with all the worksheets hidden, when I engage a macro to make the worksheet visible, I get an error. Is there a way to use the same code for the workbook?

+ 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. [SOLVED] Excel to PDF without opening workbook
    By phbryan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-21-2018, 02:48 PM
  2. [SOLVED] Hi I need a help opening an excel workbook
    By mandukes in forum Excel General
    Replies: 2
    Last Post: 06-28-2015, 11:34 AM
  3. Replies: 2
    Last Post: 05-31-2014, 02:05 AM
  4. [SOLVED] Stop an excel workbook or worksheet from opening if workbook isn't in a certain folder
    By Raulus in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-05-2013, 05:30 AM
  5. Excel Workbook not opening
    By techy101 in forum Excel General
    Replies: 0
    Last Post: 06-08-2011, 12:50 PM
  6. Opening Excel Application before Opening Workbook
    By danny2000 in forum Access Tables & Databases
    Replies: 2
    Last Post: 05-27-2011, 07:02 AM
  7. Excel workbook opening
    By rajivvyas in forum Excel General
    Replies: 1
    Last Post: 10-08-2008, 01:19 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