ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro Error stops App Macro (https://www.excelbanter.com/excel-programming/422042-macro-error-stops-app-macro.html)

steven

Macro Error stops App Macro
 
I have the following code that is run on a right click in the application:

Private Sub App_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As
Range, Cancel As Boolean)
'.....code
End Sub

But if there is an error in a macro from another excel file then this
App_SheetBeforeRightClick does not work and defaults back to the default
right click. Is there a way to make it so an error in a macro from another
excel file will not affect the App_SheetBeforeRightClick macro.

Thank you,

Steven

Gary''s Student

Macro Error stops App Macro
 
Your event macro needs Application.EnableEvents to be set to True for it to
be triggered. Another macro may disable events, do some processing, and then
re-enable events. If the other macro dies before performing the re-enable,
your macro will no longer get triggered.

You need to insure that even if the other macro dies, events get re-enabled.
--
Gary''s Student - gsnu200824


"Steven" wrote:

I have the following code that is run on a right click in the application:

Private Sub App_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As
Range, Cancel As Boolean)
'.....code
End Sub

But if there is an error in a macro from another excel file then this
App_SheetBeforeRightClick does not work and defaults back to the default
right click. Is there a way to make it so an error in a macro from another
excel file will not affect the App_SheetBeforeRightClick macro.

Thank you,

Steven


joel

Macro Error stops App Macro
 
For the right click to stop working, there is probably code in one of the
macros which turns off events

Application.EnableEvents = False


The other macro has to be fixed so when there is an error events get turned
on again.


"Steven" wrote:

I have the following code that is run on a right click in the application:

Private Sub App_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As
Range, Cancel As Boolean)
'.....code
End Sub

But if there is an error in a macro from another excel file then this
App_SheetBeforeRightClick does not work and defaults back to the default
right click. Is there a way to make it so an error in a macro from another
excel file will not affect the App_SheetBeforeRightClick macro.

Thank you,

Steven



All times are GMT +1. The time now is 01:20 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com