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
Post a Comment