+ Reply to Thread
Results 1 to 7 of 7

Automated removal of workbook_open macro

  1. #1
    Forum Contributor
    Join Date
    01-26-2005
    Posts
    108

    Automated removal of workbook_open macro

    I currently have a considerable number of workbooks being used by several people in a number of locations.
    Each of these workbooks has the same (reasonably complex) module attached.
    This module is updated (when necessary) by the user setting a flag on a control sheet and then the next time the workbook opens, the old version of the code is removed and the new version is loaded.
    This "code update" is handled (as I didn't know any other way at the time of writing it) by a workbook_open macro in each individual workbook.

    Now to the problem.
    I want to change the way this code update is handled so I need to alter the workbook_open of several hundred (probably) workbooks.
    Does anyone have any idea how I could do this in an automated way?

    I now have an "auto_open" sub in the module that is auto-updated.
    Could I use this?

    Can I use this to remove the workbook_open?

    If I replaced the workbook_open with an extra bit in the auto_open, would the auto_open in the module allow that same module to be removed and then a new version added?

    Hope I've explained it OK and thanks in advance for any suggestions.
    Tony

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Tony,

    A couple of things don't make sense here. You are using both the Auto_Open and the Worksheet_Open events in the same workbook??? If you are modifying the Workbook_Open code automatically, why are you unable to do the same to the code in the Auto_Open event?
    This module is updated (when necessary) by the user setting a flag on a control sheet and then the next time the workbook opens, the old version of the code is removed and the new version is loaded.
    This "code update" is handled (as I didn't know any other way at the time of writing it) by a workbook_open macro in each individual workbook.
    Modifying any code automatically requires you add the Visual Basic for Applications Extensibility object library to your workbook. Unless of course, your code is simply copying a new workbook, renaming it, and deleting the old workbook. I think it would be best if you post the code you are using, and provide any relative worksheet information. Like, what cell the flag is in and on which worksheet, etc.

    Sincerely,
    Leith Ross

  3. #3
    Forum Contributor
    Join Date
    01-26-2005
    Posts
    108
    Sorry for any confusion.
    When i initially set this all up I used workbook_open to handle the automated updating of the module.
    Since then I have (thanks largely to kind people in this forum) learned a lot and have recently added an auto_open sub to the module.

    I now need to modify the workbook_open code so that it does some extra "stuff".
    To do this I would need, as far as I know, have to modify each individual workbook (of which there are a great many).
    My preferred option would be to remove the workbook_open from each workbook and use auto_open in the module instead (so that each time the module is "refreshed", so would the "open" code).

    So, in a nutshell, the questions are ...

    1. Can I use some automation (I'm guessing something in the module-based auto_open) to remove the workbook_open code from the workbooks.

    2. Can I use an auto_open in module A to remove and then import module A.

    Hope I've explained it better (and thanks for your help).

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Tony,

    Where is the update information stored? How do the users access the update information?

    Sincerely,
    Leith Ross

  5. #5
    Forum Contributor
    Join Date
    01-26-2005
    Posts
    108
    Latest version of module is stored in a .BAS file on the LAN.

    Currently, workbook_open detects request for "refresh" of code from a cell on each workbook being set to "Y" then removes the module from the workbook and then imports it from the LAN.

    In case it helps, code currently in workbook_open is ...

    Please Login or Register  to view this content.

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Tony,

    Rather than have the download information on a worksheet, why not have the workbook check a file on the LAN to see if an update is available and then load the new module? You would only need to make the check when the workbook opens. This way you get out of double jeopardy with the Auto_Close/Workbook_Open events. Not a good idea to use both.

    Sincerely,
    Leith Ross

  7. #7
    Forum Contributor
    Join Date
    01-26-2005
    Posts
    108
    Thanks very much for your help Leith.
    Yep - that's a good option.
    What about the potential problem (in my head) of the auto_open being IN the module that is being removed and then imported?
    Would that work?
    Last edited by tonywig; 11-23-2007 at 04:39 AM.

+ 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