Claris Resolve: Checking for Open Worksheets

This information was provided by Claris Corporation on 16 March 1998, and incorporated into Apple Computer's Tech Info Library.
When writing a Claris Resolve script, it is sometimes necessary to determine if a particular worksheet is open. The NAME function will return the name of the current worksheet (if the current selection is a cell). When several worksheets are open, however, there is no built-in command to determine the names of all the open documents.

One technique you can use to determine whether a worksheet is currently open requires that a dummy function be placed into the Worksheet Script of each file you what to check for:

FUNCTION isOpen()
RETURN 1 {this line is not really necessary}
END FUNCTION

You can then call this function from a script and check for the existence of an error. If an error is returned, the worksheet is not open.

IF ISERR(Worksheet1:isOpen()) {replace Worksheet1 with the name of the worksheet}
MESSAGE "The worksheet is not open"
ELSE
MESSAGE "The worksheet is open"
END IF

In this example, we are simply displaying a message. Replace the message commands with code to perform the necessary operations for each case.
Published Date: Feb 18, 2012