But for some reason when connecting to the Excel Application Object, a windows error sound (ping/beep) will be played whenever you switch between workbooks. This doesn't hinder functionality of catching events, but is of course annoying and misleading. I could not figure out the reason why this is happening.
Below I have created some sample code for you to test this phenomenon. Even with no actual events hooked to the Application Object this error sound is still played upon switching workbook windows. The mere binding of ComObjConnect() seems to already cause this. This is tested and consistently happening on two PCs running Excel 2010 on Windows 7 with the current version of Autohotkey_L 1.1.30.01
Code: Select all
#Persistent
XL_App := ComObjCreate("Excel.Application")
XL_App.Visible := True
WB1 := XL_App.Workbooks.Add()
WB2 := XL_App.Workbooks.Add()
WB3 := XL_App.Workbooks.Add()
ComObjConnect(XL_App, Application_Events)
Return
class Application_Events
{
; WorkbookActivate(_WB_) {
; MsgBox % _WB_.Name " activated."
; }
; WindowActivate() {
; }
; WorkbookDeactivate() {
; }
; WindowDeactivate() {
; }
}
^Esc::ExitApp
Thank you for your help.