locked
Application_SheetBeforeRightClick Not Firing RRS feed

  • Question

  • I created an VSTO Excel 2010 addin where I am using the "Application_SheetBeforeRightClick" event.  I am having a problem with this event because it doesn't fire all the time.  It works fine when I initially open excel and open a workbook however it stop firing after I create a new workbook and it becomes active.  I thought that since this is an application event, it should fire all the time whenever any workbook worksheet combination becomes active.  Please someone help understand how to properly handle this event to make sure it fires and I can handle it everytime there is a RightClick.  Thanks in advance and Happy new year.
    Friday, January 1, 2016 8:56 PM

Answers

  • Never mind, I found the cause of my problems in an old project class I imported into addin.  In the old project the class was used to load xml files into excel and then and then terminating excel.  I forgot to remove this part and hence my problems.  Thanks Eugene for your reply.
    Sunday, January 3, 2016 11:35 PM

All replies

  • Hello John,

    Where do you subscribe to the SheetBeforeRightClick event?

    Saturday, January 2, 2016 6:10 AM
  • I have tried a few ways and in every case I have the same problem.

    Public Class ThisAddIn
    
    Private Sub ThisAddIn_Startup() Handles Me.Startup
    
    End Sub
    
    Private Sub ThisAddIn_Shutdown() Handles Me.Shutdown
    
    End Sub
    	
    Private Sub Application_SheetBeforeRightClick(Sh As Object, Target As Microsoft.Office.Interop.Excel.Range, ByRef Cancel As Boolean) Handles Application.SheetBeforeRightClick
    
    	Code here....
    	
     End Sub
     
    End Class

    Public Class ThisAddIn
    
    Public XclEvents As Excel.AppEvents_Event
    
    Private Sub ThisAddIn_Startup() Handles Me.Startup
    
     AddHandler XclEvents.SheetBeforeRightClick, AddressOf Application_SheetBeforeRightClick
     
    End Sub
    
    Private Sub ThisAddIn_Shutdown() Handles Me.Shutdown
    
    End Sub
    	
    Private Sub Application_SheetBeforeRightClick(Sh As Object, Target As Microsoft.Office.Interop.Excel.Range, ByRef Cancel As Boolean) Handles Application.SheetBeforeRightClick
    
    	Code here....
    	
     End Sub
     
    End Class
    

    Public Class ThisAddIn
    
    Public WithEvents ExcApp As Excel.Application
    
    Private Sub ThisAddIn_Startup() Handles Me.Startup
    
      AddHandler ExcApp.SheetBeforeRightClick, AddressOf Application_SheetBeforeRightClick
     
    End Sub
    
    Private Sub ThisAddIn_Shutdown() Handles Me.Shutdown
    
    End Sub
    	
    Private Sub Application_SheetBeforeRightClick(Sh As Object, Target As Microsoft.Office.Interop.Excel.Range, ByRef Cancel As Boolean) Handles Application.SheetBeforeRightClick
    
    	Code here....
    	
     End Sub
     
    End Class

    Sunday, January 3, 2016 3:58 AM
  • Never mind, I found the cause of my problems in an old project class I imported into addin.  In the old project the class was used to load xml files into excel and then and then terminating excel.  I forgot to remove this part and hence my problems.  Thanks Eugene for your reply.
    Sunday, January 3, 2016 11:35 PM
  • Hi HJohn2,

    Thanks for sharing your solution. Please mark it as answer to close this thread.

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, January 4, 2016 2:29 AM