+ Reply to Thread
Results 1 to 5 of 5

BeforeClose Cancel not working

  1. #1
    Forum Contributor
    Join Date
    05-27-2014
    Location
    Belfast, Northern Ireland
    MS-Off Ver
    2007 & 2010
    Posts
    273

    BeforeClose Cancel not working

    I'm hoping someone can identify the issue here:
    I have this code in the ThisWorkbook module:
    Please Login or Register  to view this content.
    But the event doesn't cancel.

    I get the msgbox so I know that the If statement is good.

    When I step through and debug the value of Cancel before the code sets it to True, the value is False (as expected). After the code sets it to True and I debug the value of Cancel, the value is True (as expected).

    But the event is never cancelled and the workbook always closes.

    I have also tried using ByRef in the parameters for the procedure but nada.

    Driving me insane!
    Please click *Add Reputation if I've helped

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: BeforeClose Cancel not working

    Works for me in a blank workbook after I change 'Sheet 1' to 'Sheet1'.

    Any other code in the workbook?
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    05-27-2014
    Location
    Belfast, Northern Ireland
    MS-Off Ver
    2007 & 2010
    Posts
    273
    Quote Originally Posted by Norie View Post
    Works for me in a blank workbook after I change 'Sheet 1' to 'Sheet1'.

    Any other code in the workbook?
    No, no other code.

    However, that got me thinking. There's an add-in we use at work that changes the save behaviour of MS Office Apps so that all documents are saved through the API of a document management system (HP TRIM). I wonder could that be continuing the close event?

    Could I use DisableEvents or something similar to deal with this? If so where would I use it?

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: BeforeClose Cancel not working

    Not sure if disabling events would help, if you disabled events then BeforeClose wouldn't be triggered and it might not even affect the add-in.

  5. #5
    Forum Contributor
    Join Date
    05-27-2014
    Location
    Belfast, Northern Ireland
    MS-Off Ver
    2007 & 2010
    Posts
    273

    Re: BeforeClose Cancel not working

    It looks like it was the Add-In that was causing the problem. A few tests with it installed and uninstalled revealed the truth.

    Toying with the idea of turning the Add-In off in the Workbook_Open event until the required cells have been completed. Not ideal but a workaround nonetheless.

    As always Norie, thanks for your help. You got me on the right track. I'd give you rep but it looks like I have to spread the love before I can give to you again. lol That's how much you help me!

+ 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: 11-19-2015, 03:08 PM
  2. [SOLVED] BeforeClose event not running/working when file is closed through VBA in another file
    By jaimelwilson in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-27-2014, 03:43 AM
  3. Replies: 1
    Last Post: 03-08-2012, 03:03 AM
  4. Cancel Close outside BeforeClose Event
    By yawnzzzz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-01-2011, 11:43 AM
  5. Beforeclose sub suddenly stopped working
    By cuewoz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-04-2010, 12:29 PM
  6. [SOLVED] Workbook_BeforeClose - Cancel not working
    By sebt in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-31-2006, 12:40 PM
  7. BeforeDoubleClick Cancel=True not working
    By Reggie in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-19-2005, 11:05 PM

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