HOWTO: How to switch off alerts and warnings during a macro

Reference: Q0046

Article last modified on 15-Feb-2008


The information in this article applies to:

  • XLL+ for Visual Studio .NET - 3, 4.1, 4.2, 4.3.1, 5.0
  • XLL+ for Visual Studio 6 - 3, 4.1, 4.2, 4.3.1, 5.0
  • XLL+ for Visual Studio 2005 - 5.0

How to switch off alerts and warnings during a macro

Issue

I would like to delete some worksheets in a macro function, but I would like to do so without having the message boxes. It should be the equivalent of the VBA: Application.DisplayAlerts = False.

Solution

To switch off alerts, use the following:

static int xlcError = 84;
int rc = CXllApp::Excel(xlcError, 1, &CXlOper(FALSE));

To switch alerts back on again:

static int xlcError = 84;
int rc = CXllApp::Excel(xlcError, 1, &CXlOper(TRUE));