Im stumped... This all started with my excel 2010 not retaining my option to "Enable AutoComplete for cell values" after I close a workbook. So I wrote an addin (*.xlam) to handle excel events using a class module to always enable auto complete upon workbook open. Or so I thought on workbook open... for some reason the event workbook open and workbook before close events do not work. I know they run because I've run them all individually with a msg box and they all appear. When it comes to setting the enable auto complete property only the selection change event works for me.
I've shown a couple variations of when I was trying to enable auto complete. Can someone explain why only the selection change works? I would have figured once the class was initialized and "App" was set to the application I could set that property at any time after. What am I missing?
Add-In Code: ThisWorkbook
Option Explicit
Private ExcelEvents As clsExcelEvents
Private Sub Workbook_Open()
Set ExcelEvents = New clsExcelEvents
End Sub
Add-In Code: Class Module - clsExcelEvents
Option Explicit
Private WithEvents App As Application
Private Sub Class_Initialize()
Set App = Application
End Sub
Does NOT work
Private Sub App_WorkbookBeforeClose(ByVal Wb As Workbook, Cancel As Boolean)
App.EnableAutoComplete = True
End Sub
Does NOT work
Private Sub App_WorkbookOpen(ByVal Wb As Workbook)
App.EnableAutoComplete = True
End Sub
WORKS!
Private Sub App_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
App.EnableAutoComplete = True
End Sub
Bookmarks