+ Reply to Thread
Results 1 to 2 of 2

Are problems with the Workbook_BeforeClose due to my environment?

  1. #1
    Registered User
    Join Date
    09-20-2012
    Location
    Wellington, New Zealand
    MS-Off Ver
    Excel 2003
    Posts
    63

    Are problems with the Workbook_BeforeClose due to my environment?

    Hi all,

    I am having constant problems with the Workbook_BeforeClose event in my workplace. Basically, the Workbook_BeforeClose doesn't allow me to do a whole host of things - Protect/Unprotect sheets, Application.DisplayAlerts = False, Thisworkbook.Save. With all of these, the code appears to run with each of them. However, none of them actually work. What I mean is that I have a piece of code that says "Worksheet("xxx").Protect Password", which runs fine, but it does not actually protect the worksheet, it remains Unprotected directly after this code runs (as I can see via the UI and subsequent bugs). The same behaviour occurs with the others.

    Now I can find numerous examples, like this: http://www.vbaexpress.com/kb/getarticle.php?kb_id=379 where all the things I want should actually work. But they don't. And I am wondering why?

    My workplace is using Excel 2003 (11.8169.8172) SP3. Its a very tightly controlled banking environment and as I have little actual say in hotfixes or upgrades etc its unlikely to change. My questions are:

    Has anyone had similar problems? If so, was it in Excel 2003? And if you fixed it, was it because of a hotfix?
    ....or maybe....
    Is this due to a corrupt file?

    My file reads and writes from/to databases before closing, which is why I really need this event to work properly.

    Thanks!
    Last edited by blobbles; 09-29-2012 at 03:31 AM.

  2. #2
    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
    48,122

    Re: Are problems with the Workbook_BeforeClose due to my environment?

    As far as I am aware, if macros are allowed to be run, they'll run. I don't know of a way of limiting what you do with them when they run ... though that's not to say it can't be done. Everything is possible

    You may want to share the actual code and/or a sample workbook.

    Regards, TMS
    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


+ 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