View Raw SPL
/*****************************************************************************
* *
* XLQUIT.SPL Copyright (C) 2024 DSP Development Corporation *
* All Rights Reserved *
* *
* Author: Randy Race *
* *
* Synopsis: Closes Excel Applicationk via Automation *
* *
* Revisions: 10 Dec 2024 RRR Creation *
* *
*****************************************************************************/
#if @HELP_XLQUIT
XLQUIT
Purpose: Closes the current Excel application via ActiveX Automation.
Syntax: XLQUIT(verbose)
verbose - Optional integer, the message flag.
0: do not display Excel messages (default)
1: display Excel messages
Returns: 1 if successful, else an error
Example:
xlinit();
xlput("A1:C10", ravel(1..30, 10));
xlshow(1);
xlquit();
The values 1..30 are shaped into a 10x3 array and written to
cells A1 through C10 of Excel. Excel is made visible. The
Workbook is not saved and Excel is immediately closed without
prompting.
Example:
xlinit();
xlput("A1:C10", ravel(1..30, 10));
xlshow(1);
xlquit(1);
Same as above except the VERBOSE is TRUE. Because Excel is
visble and the Workbook was not saved, Excel prompts to
optionally save the Workbook.
Remarks:
XLQUIT connects to the running instance of Excel.
XLQUIT can terminate the Execl instance even if it is visible.
See Also:
Xlclear
Xlget
Xlinit
Xlput
Xlsave
Xlsaveas
#endif
/* close Excel application */
xlquit(verbose)
{
local xl, status = -1;
if (argc < 1)
{
verbose = 0;
}
/* current instance if any */
xl = xlconnect();
if (isobject(xl))
{
/* Excel messages */
xl.displayalerts = verbose;
status = xl.workbooks.close();
if (status >= 0)
{
/* terminate application */
status = xl.quit();
xldisconnect();
}
}
return(status);
}