none
Beep when switching from one workbook to another‎ RRS feed

  • Question

  • A similar question has been asked before, but it hasn't been answered.

    I have this code in ThisAddin.cs in my application level add-in based on VSTO:

    this.Application.WorkbookActivate += new Excel.AppEvents_WorkbookActivateEventHandler(WorkbookActivate);

    My definition of WorkbookActivate is placed in the same file and it entirely empty:

    private void WorkbookActivate(Excel.Workbook wb)
    {
    }

    When I open two Excel sheets (where the second one is opened by choosing File->New->Blank worksheet->Create) and switch between them by clicking on the buttons in the Taskbar in Windows 7 or using Alt-TAB there is a loud beep. The beep doesn't happen everytime, but almost every time I make a switch between the workbooks this way. When I use View->Switch windows in Excel there are never any beeps.

    If I remove the line with += the beep goes away.

    I can't see that I am doing anything that can cause a beep to go off. I hope someone can find a solution to this problem as our customers find this beeping rather annoying or alternatively can lead me to ways to debug this.

    Thursday, November 15, 2012 3:31 PM

All replies

  • is there actually any code in that event handler? or it can be empty to reproduce this issue?
    Thursday, November 15, 2012 8:27 PM
  • is there actually any code in that event handler? or it can be empty to reproduce this issue?
    My event handler is entirely empty as I write. Naturally, I've tried to insert some code. My code get executed OK , but the beeping persists.
    Friday, November 16, 2012 1:36 AM
  • i repeated your steps, no beeping, win7, excel 2010 64 bit.
    Friday, November 16, 2012 9:37 AM
  • i repeated your steps, no beeping, win7, excel 2010 64 bit.

    Hi DamianD

    Thanks for spending time on this.

    I have also made some tests with some new projects that I have started from scratch. I get the problem with the beeps everytime. The beep is a Windows Default Beep (ding.waw).

    I have disabled all other add-ins with no change in behaviour.

    This thread goes over the same problem, which seems to have existed also for Excel 2007:

    http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/3b044a99-d6e9-4914-a51e-a318ff0a0f45

    My system is running Windows 7 Ultimate N (service pack 1) and I've created my projects from scratch using Visual Studio 2010.

    If someone could give me a hint on how to find the source of the beep, I'll be very happy. 

    Thursday, November 22, 2012 10:40 AM
  • I have also experienced this.

    Its been there in Excel 2003 and Excel 2010. I have no way of eliminating this issue. 

    My code:

    private void InitEvents()
    {
        if (m_initEvents) return;
        try
        {
            Globals.ThisAddIn.Application.WorkbookActivate += new Microsoft.Office.Interop.Excel.AppEvents_WorkbookActivateEventHandler(Application_WorkbookActivate);
          m_initEvents = true;
        }
        catch(Exception){}
    }
    private void Application_WorkbookActivate(Microsoft.Office.Interop.Excel.Workbook Wb)
    {
        UpdateButtons();
    }
    
    private void UpdateButtons() 
    {
        try
        {
            bool EdittingHead = ies3Common.EdittingHead;
            btnHeaderOk.Enabled = EdittingHead;
            btnEditHeader.Enabled = !EdittingHead;
            btnNewID.Enabled = !EdittingHead;
            btnNewRev.Enabled = !EdittingHead;
            btnPublishRevision.Enabled = !EdittingHead;
        }
        catch (Exception) { }
    }

    Wednesday, January 2, 2013 6:41 AM