VBA Application Events in Excel AddIn -


i making excel 2010 addin , trying add code application event application_workbookactivate(byval wb workbook)

however, module inside addin cannot have these events. tried making classmodule events , initializing on addin's load. got idea after reading this.

here have in addin's class "eventlistener:"

dim withevents app application  private sub app_workbookactivate(byval wb workbook)     debug.print "workbook activated:"; wb.name     call myaddinmodule.refreshvisibility end sub 

and here have in module "myaddinmodule:"

public listener eventlistener public myribbonui iribbonui  ' ribbon callback : runs when ribbon loaded public sub onloadribbon(ribbon iribbonui)     ' reference ribbon     set myribbonui = ribbon     debug.print "ribbon reference set"     set listener = new eventlistener end sub  public sub refreshvisibility()     myribbonui.invalidate     debug.print "ribbon invalidated" end sub 

unfortunately did not work. not possible declare withevents object in normal coding module , class object didn't fire expected.

is there better way have application events coded addin?


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -