Skip to main content

Robot Task Activities - Excel​

The Excel activities start Microsoft Excel or attach to it, set how it behaves, and quit it. Every other Excel activity must be placed inside one of the two container activities, New Excel or Attach to Excel.

The Excel category in the activity list, with the New Excel, Attach to Excel, Quit Excel, Set Excel Visibility, Set Excel Interactivity, Set Display Alerts and Set Full Screen Mode activities

Excel must be installed in the desktop session the Robot Task runs in.

Required nesting​

The Excel activities work on an Excel application supplied by a parent container, either New Excel or Attach to Excel. Activities from the Excel Workbook, Excel Sheet, Excel Cell, Excel Row, Excel Column and Excel Macros categories go inside the container's Do body. Most Excel activities outside a container are reported as a validation error; Run Macro fails when it runs.

Sequence
New Excel
Do
Create Workbook
Set Cell value
Save as Workbook
Close Workbook
Quit Excel

New Excel​

Starts a new Excel application and makes it the one the child Excel activities in its Do body work on.

The New Excel activity with an empty Do body

Properties​

The Properties pane of the New Excel activity, with the DisplayAlerts, IsInteractive, IsVisible and WaitForReady properties

  • DisplayAlerts: whether Excel shows alerts and messages, such as overwrite confirmations; cleared by default
  • IsInteractive: whether Excel accepts keyboard and mouse input; checked by default; when cleared, Excel blocks all input except input to windows opened by your code
  • IsVisible: whether the Excel window is visible; checked by default
  • WaitForReady: how many seconds to wait for Excel to be ready, "120" by default; if Excel is not ready in time, the activity fails

When the Do body ends, VisualCron releases its connection to Excel but does not close Excel. Add a Quit Excel activity to close it.


Attach to Excel​

Attaches to an Excel application that is already running in the session, and makes it the one the child Excel activities in its Do body work on. It has the same properties as New Excel, and applies them to the running Excel when it attaches. If no Excel is running, the activity fails.

If more than one Excel application is running in the session, Windows decides which one Attach to Excel uses. Keep only one Excel running when a sequence attaches to it.

Use Attach to Excel to return to a workbook that was opened earlier in the Task, for example to write to an exception log from inside a loop. See Data Processing & Logging.


Quit Excel​

Quits the Excel application.

The Quit Excel activity

This activity must be inside a parent Excel activity, either New Excel or Attach to Excel.

warning

With DisplayAlerts cleared, which is the default, Quit Excel closes every open workbook without saving it. Inside Attach to Excel it quits the Excel that was already running, including workbooks a person has open. Save first with Save Workbook or Save as Workbook.

A Quit Excel activity inside the Do body of a New Excel activity


Set Excel Visibility​

Shows or hides the Excel application.

The Set Excel Visibility activity, with the Is Visible check box

  • Is Visible: check to show Excel, clear to hide it

Set Excel Interactivity​

Sets whether Excel accepts keyboard and mouse input. When this is cleared, Excel blocks all input except input to windows opened by your code.

  • Is Interactive: check to accept input, clear to block it

Set Display Alerts​

Sets whether Excel shows alerts and messages, such as overwrite confirmations.

  • Display alerts: check to show alerts, clear to suppress them

Set Full Screen Mode​

Turns Excel's full screen mode on or off.

  • Full screen: check for full screen mode, clear for the normal window

Tips​

  • DisplayAlerts is cleared by default, so Excel does not stop an unattended Job with a confirmation such as "a file with this name already exists". The other side of this is that Excel then takes the default answer without asking: a Save as Workbook to an existing path replaces that file
  • Always end an Excel workflow with Close Workbook followed by Quit Excel. Excel processes left running accumulate in the session and eventually use up its memory
  • Put the Quit Excel activity in the Finally block of a Try Catch activity so that Excel is closed even when the workflow fails partway through
  • Clear IsVisible for Jobs that run unattended, so that someone using the session cannot interfere with Excel
  • Increase WaitForReady on a busy machine. Excel can take several seconds to become responsive after it starts