Skip to content

Excel Save (Session)

Type: excel-save  ·  Package: Excel Activities v1.0.6  ·  Output: —

Saves to disk the changes of an Excel session without closing it. Useful for intermediate saves during a long process (so you don’t lose progress), or to save a copy to another path (like “Save As”).

It writes the session’s changes to the file. If you set savePath, it writes a copy to that path; if you leave it empty, it saves to the original path. Either way, the session stays open.

  • savePath does not change the session’s path: later Excel Save calls without savePath and the final Excel Close save to the original path again.
  • If a file already exists at the destination, it is overwritten. Missing folders are created.
  • The destination extension must be .xlsx, .xlsm, .xltx or .xltm.
  • Inside the body of an Excel Open you can omit session.
  • On a session that is already closed, it does nothing.
ParameterTypeDefaultDescription
sessionZoanExcelSession—The session returned by Excel Open.
ParameterTypeDefaultDescription
savePathstring—Save a copy to a different path (Save As). Leave empty to save to the original path.

This activity does not return a value.

MessageCause and fix
'session' must be a valid Excel session (use excel-open).session is empty or is not an Excel session. Pass the output variable of Excel Open.
Extension 'pdf' is not supported. Supported extensions are '.xlsx', '.xlsm', '.xltx' and '.xltm'.savePath has a non-Excel extension. For a PDF, save and then use Excel to PDF.
The process cannot access the file '…' because it is being used by another process.The destination file is open in Excel or another program. Close it and retry.
Workbooks need at least one worksheet.The session started from a file that did not exist and has no sheet yet. Write something before saving.

Intermediate save inside a long loop, and a final dated copy:

Excel Open path = asset("accumulated.xlsx") → output: workbook
For Each items = batches itemVariable = batch
└─ activities:
Append Excel Rows session = workbook data = batch
Excel Save session = workbook // intermediate save, just in case
Excel Save session = workbook savePath = "C:/backups/accumulated_" + today().ToString("yyyyMMdd") + ".xlsx"
Excel Close session = workbook