• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA Misfire after workbook is closed

Chanzaiming

New Member
Hi,

I have found some codes from the internet to "disable" the Ctrl+X.
Everything works fine within the workbook.
However, when the workbook that contained the VBA is closed, and the excel application is still running(either due to other workbook is open or just a blank window), I noticed that when I press Ctrl+X, the VBA opens my workbook and tried to run the sub that disable the Ctrl X, and freeze excel.

Any idea how to avoid the misfire from happening?

I understand that shutting down the application completely can achieve that, but the users may have something else open and may not want to close yet.

I have attached the workbook here.
Warning: it will gets into a loop(still trying to figure out why), you can hit ESC to get out of it.
 

Attachments

  • troubleshoot.xlsm
    270.3 KB · Views: 2
Hi Yuming ,

Please remember this one important point :

In the Workbook_BeforeClose event procedure , do not execute the ThisWorkbook.Close command ; this will either send Excel into an infinite loop or cause it to crash.

Exiting the Workbook_BeforeClose event procedure with Cancel = False will automatically close the workbook.

See your file , and comment.

Narayan
 

Attachments

  • troubleshoot.xlsm
    270.1 KB · Views: 4
Hi Yuming ,

Please remember this one important point :

In the Workbook_BeforeClose event procedure , do not execute the ThisWorkbook.Close command ; this will either send Excel into an infinite loop or cause it to crash.

Exiting the Workbook_BeforeClose event procedure with Cancel = False will automatically close the workbook.

See your file , and comment.

Narayan

Thanks Narayan!
So the "misfire" is actually caused by the loop/ghost because the worksheet was not actually closed and thus triggered the event when Ctrl+X is press?
 
Hi Yuming ,

I am not sure , but the other change I made was to call the ToggleCutCopyAndPaste procedure with (True) , so that CTRL+x would revert to its normal definition.

Narayan
 
Back
Top