CloseAll Method

The CloseAll method closes all open worksheets.

Syntax

boolRet = objMC.CloseAll ([MCSaveOption SaveOption])

Element

Description

boolRet

Return value indicating success or failure.

objMC

A Mathcad application object.

MCSaveOption

Optional argument specifying how to handle unsaved worksheets. The default is McPromptToSaveChanges.

Remarks

The CloseAll method can fail if the save failed to complete for any reason, such as insufficient disk space or canceling out of the save operation.

To close a single worksheet, use the Close method of the Worksheet class.

Example

The following Visual Basic code demonstrates usage of the CloseAll method. If the optSave flag has been set (in this case, via user interaction), the CloseAll method is invoked with the corresponding argument enumerated in MCSaveOption.

Select Case optSave

Case None

'Default option

objMathcadApp.CloseAll

 

Case Lose

'Lose Changes

objMathcadApp.CloseAll mcDiscardChanges

 

Case Prompt

'Ask user whether to save

objMathcadApp.CloseAll mcPromptToSaveChanges

 

Case Save

'save changes

objMathcadApp.CloseAll mcSaveChanges

 

Case Else

'invalid options - unsuccessful closing of worksheets

MsgBox ("Close Failed")

End Select