+ Reply to Thread
Results 1 to 9 of 9

Have workbook open specific worksheet when workbook opens

  1. #1
    Spammer
    Join Date
    11-21-2014
    Location
    California
    MS-Off Ver
    2010
    Posts
    387

    Have workbook open specific worksheet when workbook opens

    In running a google search, I came across the following code to have a worksheet open automatically when a workbook opens...

    Yet it does not seem to function properly. (I am trying to open sheet "Info") attached a sample here..... Any thoughts on how to fix this???

    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,819

    Re: Have workbook open specific worksheet when workbook opens

    What do you mean when you say, "it does not seem to function properly"? It seems to function just fine for me on my machine.

    My only recommendation at this point is to add a stop statement at the top of the procedure
    Please Login or Register  to view this content.
    Then, when you open the workbook, it should bring up the VBA editor in debug mode at the Stop statement and allow you to test and debug the code to see why it is not working.
    If it fails to bring up the VBA editor in debug mode paused at the Stop statement, then you know that it is failing to execute the workbook_open() procedure, and can work on figuring out why it won't call the procedure.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: Have workbook open specific worksheet when workbook opens

    Yep. works for me too.

    Suspect that means that you have not enabled macros, or Event Handling is set to False (if it is, use Application.EnableEvents = True)

    Have you checked that the Open Event is being executed?
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Spammer
    Join Date
    11-21-2014
    Location
    California
    MS-Off Ver
    2010
    Posts
    387

    Re: Have workbook open specific worksheet when workbook opens

    When i open the file, it does not open that Worksheet. I am relatively new to Macros... so not entirely sure what you mean by "Open Event" being executed. I do have macros enabled.... and attached a copy of the macro workbook up above.

  5. #5
    Spammer
    Join Date
    11-21-2014
    Location
    California
    MS-Off Ver
    2010
    Posts
    387

    Re: Have workbook open specific worksheet when workbook opens

    If i open the file that is attached, it does NOT open the tab "info" however no errors pop up either.
    If i hit Alt F11 and open the code...... if i hit the "play" arrow, the code runs as it should when the file opens... but it just does not run automatically when the file opens.

  6. #6
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,819

    Re: Have workbook open specific worksheet when workbook opens

    so not entirely sure what you mean by "Open Event" being executed.
    Meaning that the "open event" procedure should automatically execute when the workbook opens. The reason I suggested adding the Stop statement was to provide a way for you to see when Excel/VBA chooses to execute the code. If you add the stop statement, save the file, then reopen, you should end up with the procedure paused at that statement. If it does not automatically come up, then it is not executing the procedure as it should.

    As both TMS and I have noted, it seems to work just fine for us, so there must be something different about your Excel environment. Did you check the Application.enableevents property to see if it had been set to false? https://msdn.microsoft.com/en-us/lib.../ff821508.aspx

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: Have workbook open specific worksheet when workbook opens

    Press Alt-F11 to open the VBE.
    If the Immediate Window is not displayed, press Ctrl-G
    Type: ?Application.EnableEvents and press Enter

    If it returns False, type: Application.EnableEvents = True and press Enter

    Close the workbook and open it again

  8. #8
    Spammer
    Join Date
    11-21-2014
    Location
    California
    MS-Off Ver
    2010
    Posts
    387

    Re: Have workbook open specific worksheet when workbook opens

    event handling was set to false... it did work when i changed it to True, then it did work. So how do i make sure that this is set to true for other files/computers that this would be used on??? Or is that a setting that goes with the excel sheet when it is downloaded to other computers?

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: Have workbook open specific worksheet when workbook opens

    Pretty sure it's set for the session and will affect all workbooks. Closing and restarting Excel should reset it.

+ 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. Replies: 3
    Last Post: 07-12-2014, 06:04 AM
  2. Replies: 1
    Last Post: 03-10-2014, 05:20 AM
  3. Open Menu worksheet when Workbook opens
    By rockycj in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-14-2008, 02:36 PM
  4. Open workbook to a specific worksheet
    By mwc0914 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-19-2007, 11:18 AM
  5. [SOLVED] When I open a workbook, how can I choose which worksheet opens?
    By josephdmcc in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-12-2006, 12:10 PM
  6. Open a specific worksheet in workbook
    By leem in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-09-2005, 12:05 PM
  7. Open workbook to specific worksheet
    By Dave in forum Excel General
    Replies: 2
    Last Post: 05-02-2005, 04:06 PM
  8. [SOLVED] On open workbook go to a specific worksheet
    By Andy Josolyne in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-02-2005, 10:06 AM

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