+ Reply to Thread
Results 1 to 5 of 5

Workbook_Open() events won't run

  1. #1
    Registered User
    Join Date
    01-22-2016
    Location
    Canada
    MS-Off Ver
    365
    Posts
    41

    Workbook_Open() events won't run

    Hi, I have a workbook that has several macros running fine; however, when I close the workbook and do not exit the Excel Application, but then reopen the same workbook I find events in the Workbook_Open() won't run, but yet all of the macros still run. I don't want the users to have to completely exit the Excel Application every time they finish using this workbook.

    I have turned off the toolbar in the Workbook_Open and then turned the toolbar back on when the user exits the workbook via a macro button that has the code in Module1.


    In ThisWorkbook...
    Please Login or Register  to view this content.


    In Module1...
    Please Login or Register  to view this content.
    Any ideas why the events in Workbook_Open() won't run when I reopen the workbook?

    I thank you in advance for your help.

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

    Re: Workbook_Open() events won't run

    Following the logic in the ExitWorkbook() procedure:

    1) you disable events
    2) you enable alerts
    3) you reset a toolbar back to its state before the workbook_open event was run
    4) then close the workbook

    What seems to be missing is a statement that reenables events. While this isn't my programming expertise, I suspect that, as long as Excel remains open after this procedure is run, events will remain disabled. When Excel is closed and reopened, the enableevents toggle is reset back to true.

    Again, this isn't my expertise, so I'm not sure if it is as simple as adding an application.enableevents=true statement to the end. It seems that events are remaining disabled because you never tell Excel to reenable events.
    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,436

    Re: Workbook_Open() events won't run

    @MrShorty: what it says on the tin Application.EnableEvents = False

    .EnableEvents is an Application level property so, if you set it False, you must set it back to True at some point within the instance of Excel otherwise NO events will fire.
    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
    Registered User
    Join Date
    01-22-2016
    Location
    Canada
    MS-Off Ver
    365
    Posts
    41

    Re: Workbook_Open() events won't run

    Thank you TMS. It didn't dawn on me .EnableEvents was an application level property. My dilemma has been solved. Thank you very much

  5. #5
    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,436

    Re: Workbook_Open() events won't run

    You're welcome. Thanks for the rep.

+ 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] Issue with sequence of events: Workbook_open, Workbook_sheetActivate, and custom Ribbon
    By dommit64 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-26-2020, 05:38 PM
  2. [SOLVED] Application.Enable Events Property stopping Workbook_Open() Event
    By Sc0ut in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-07-2016, 05:09 PM
  3. Private sub workbook_open code running workbook_open code from other project
    By marshall_massive in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-20-2013, 06:07 PM
  4. Excel 2007 workbook_open events are not working
    By ljoseph in forum Excel General
    Replies: 1
    Last Post: 05-11-2010, 01:51 PM
  5. Updating workbook_open from workbook_open
    By tonywig in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-24-2007, 07:39 AM
  6. [SOLVED] Using Workbook_AddinInstall -vs- Workbook_Open Events
    By Bill Schanks in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-23-2005, 12:25 AM
  7. [SOLVED] Workbook_Open - Multiple Events not all working
    By Punsterr in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-06-2005, 03:05 AM

Tags for this Thread

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