+ Reply to Thread
Results 1 to 5 of 5

How to run VBA on file open and close?

  1. #1
    Registered User
    Join Date
    11-13-2003
    Location
    California
    MS-Off Ver
    2013
    Posts
    37

    Question How to run VBA on file open and close?

    Afternoon everyone,

    I've been searching for this but can't find anything to push me in the right direction so I'm asking for some help.

    What I'm trying to do is figure out where to put VBA code that will run as soon as the file is opened even without having to hit a button or anything.

    And then also if it's possible, where to put code that will execute as the file is closing as well.

    Thanks for the help!

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    These links should help

    Code goes in ThisWorkbook

    http://www.cpearson.com/excel/events.htm


    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Registered User
    Join Date
    11-13-2003
    Location
    California
    MS-Off Ver
    2013
    Posts
    37
    Once again this site pulls through!

    Thank you...

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Glad it helped

    VBA Noob

  5. #5
    Forum Contributor boylejob's Avatar
    Join Date
    02-22-2007
    Location
    Forest City, NC
    MS-Off Ver
    2003
    Posts
    562
    Bimmerman,

    The document VBAnoob pointed you to is an excellant reference. Pay very close attention to the section call Order of Event Procedures.

    I was recently helping someone create a log that tracked changes to a worksheet. We had put the code in the Workbook_BeforClose event, but were not capturing everything. Ended up we needed it in one of the events that were a little lower down on the list. This is particularly important if you have alerts turned off. The Pearson document proved to be invaluable in this situation.

    Just thought I would throw that out there. It might help you someday!
    Sincerely,
    Jeff

+ 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