Connecting an Excel Application via ComObjConnect causes a Windows error sound when switching between workbooks

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
b00kay
Posts: 3
Joined: 11 Dec 2018, 19:39

Connecting an Excel Application via ComObjConnect causes a Windows error sound when switching between workbooks

11 Dec 2018, 20:14

I have a problem with connecting my Excel Application via ComObjConnect. The connection itself is working and events are triggered as expected.
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
The event handling methods are deactivated and here just for reference and playing around with. No matter if zero or multiple methods are hooked, the problem remains.
Thank you for your help.
User avatar
TLM
Posts: 1608
Joined: 01 Oct 2013, 07:52
Contact:

Re: Connecting an Excel Application via ComObjConnect causes a Windows error sound when switching between workbooks

11 Dec 2018, 23:09

I can only think of disabling alerts themselves XL_App.Application.DisplayAlerts := False
b00kay
Posts: 3
Joined: 11 Dec 2018, 19:39

Re: Connecting an Excel Application via ComObjConnect causes a Windows error sound when switching between workbooks

12 Dec 2018, 10:10

TLM wrote:
11 Dec 2018, 23:09
I can only think of disabling alerts themselves XL_App.Application.DisplayAlerts := False
Sadly this is not in any way related to the applications alerts. I've tested this previously and it doesn't help. The error sound seems to be originating from windows and not Excel. Any other thoughts?
awel20
Posts: 211
Joined: 19 Mar 2018, 14:09

Re: Connecting an Excel Application via ComObjConnect causes a Windows error sound when switching between workbooks

12 Dec 2018, 10:33

I did a quick search. This seems to be a known issue for anything that monitors Office events. I found a lot of people complaining about various COM add-ins causing this. Unfortunately I could not find a better answer than this: https://stackoverflow.com/questions/179 ... -workbooks
Basically the suggested soutions are 1) disable the windows sound. or 2) open the workbooks in different excel instances

also
https://www.mrexcel.com/forum/power-bi/ ... books.html
https://www.mrexcel.com/forum/excel-que ... s-why.html
https://social.msdn.microsoft.com/Forum ... to-another
https://social.msdn.microsoft.com/Forum ... ion-events
User avatar
FanaticGuru
Posts: 1907
Joined: 30 Sep 2013, 22:25

Re: Connecting an Excel Application via ComObjConnect causes a Windows error sound when switching between workbooks

12 Dec 2018, 20:37

awel20 wrote:
12 Dec 2018, 10:33
I did a quick search. This seems to be a known issue for anything that monitors Office events.
Don't think of it as a bug, this is an undocumented "feature" that lets you know your application is being monitored. :crazy:

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: popdeg, slishnevsky, Spawnova and 167 guests