SuppressExcelAlerts

Revision as of 17:38, 3 August 2015 by Lchrisman (talk | contribs) (Created page with "category:System Variables ''new to Analytica 4.7'' = Description = When SuppressExcelAlerts is set to true (1), the Excel property [http://msdn.microsoft.com/en-...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

new to Analytica 4.7

Description

When SuppressExcelAlerts is set to true (1), the Excel property DisplayAlerts is set to false when SpreadsheetOpen is called.

The system variable has an effect only within SpreadsheetOpen. When SpreadsheetOpen returns, the DisplayAlerts will be false, but if anything resets it to true afterwards, other spreadsheet functions will start displaying alerts again.

Purpose

When a model, or an ADE-based application uses Excel as a component to access workbooks, Excel will sometimes display message boxes to the user with information or questions. If these message boxes appear on screen other than the user's screen, then the calling application will hang (i.e., become non-responsive) as it waits for the Excel call to return, which will never happen since the user has no way of knowing the question is even there. By suppressing these, you can prevent such applications from hanging.

Generally in Desktop Analytica you should not set this, since Excel should also be running on your desktop. If Excel needs to display a message box, you should be able to see it, and you probably do want to see it. The main purpose for this is for use in Web Applications (such as Analytica Cloud Player), where the user interacting through the web interface would never see the servers console where the Excel message box would most likely appear.

Usage

In an ADE-based web application, your code should set this system variable just prior to a call to OpenModel, for example:

CAEngine ade = new ADE.CAEngine;
ade->SendCommand("SuppressExcelAlerts : 1");
ade->OpenModel("SomeModelName.ana");

Lifetime

The SuppressExcelAlerts system variable is not saved with your model. If you set its value before a call to OpenModel(), its value will be the same after the model loads, but the value will be reset to false (0) if a model is closed, so your code should set it every time prior to a call to OpenModel().

Setting it prior to OpenModel() ensures that it is set in the event that a model proactively opens a spreadsheet at model load time.

The DisplayAlerts property is a property of the Excel application instance, and not of the individual workbook. So once it is set or changed, all workbook instances are impacted. If you have a web application running, but you use the Excel UI on the same server from a desktop, the two will interfere with each other. Your desktop usage may in fact set the DisplayAlerts again. If you feel you need to hedge against this in your web-based application, you may need to clear the DisplayAlerts property prior to any operation that might result in an Excel message box. For example, during a Save As, a message box will appear if the file name already exists, so to suppress this you would need you model to do the following, where wb is the name of your model variable that holds the workbook.

Var prevDA := wb->Application->DisplayAlerts;
wb->Application->DisplayAlerts := false;
wb->SpreadsheetSave("NewFilename.ana");
wb->Application->DisplayAlerts := prevDA;

Note: The above code requires the Enterprise edition when run on Analytica desktop, since it uses the COM Integration feature.

If your web-application is the only code that would be using Excel directly on that server, this extra protection around spreadsheet functions is unnecessary. To run your model on ACP, you do not need to worry about protect spreadsheet calls in this fashion.

See Also

Comments


You are not allowed to post comments.