**Start a new topic**

## Unable to close Excel Instance using Process Robot

**15 Comments**Sorted by

**Popular**

Yes they are being launched by different Excel Instance and Variable name,closing of Excel instance works fine for 4 consecutive Excel files with 2 Excel files open at a time of an iteration. but for 11 Excel files processing though only 2 Excel Instances are being opened at a time, with different variable name and Instance name, getting errors while Close Excel Activity.

Smitha,

set %counter_1% = 0

Create New List - %Excel_A_instance_list%

set %counter_2% = 0

Create New List - %Excel_B_instance_list%

**Loop ..... for each pair set of 2 excel files to open concurrently and process**

*add your code here to Retrieve your next set of 2 excel files to open concurrently and process*

**... Open Excel File A
**

increase %counter_1% by 1

add item %""% to list - *%Excel_A_instance_list[counter_1]**%* (... add empty string as list item )

Launch Excel File_A --- __specify excel instance variable__: *%Excel_A_instance_list[counter_1]%*

*... Open Excel File B*

increase %counter_2% by 1

add item %""% to list - *%Excel_B_instance_list[**counter_2]**%* (... add empty string as list item )

Launch Excel File_B --- __specify excel instance variable__: *%Excel_B_instance_list[counter_2]%*

.... do you processing of set/pair of Excel A and Excel B ( 2 concurrently opened excel instances)

.... Close Excel File_A %Excel_A_instance_list[counter_1]%

.... Close Excel File_B %Excel_B_instance_list[counter_2]%

**End Loop ( looping while pairs of excel files to process )**

With above, we are actually using different excel instance variables for each file to be opened and closed. The above works on excel 64 bit version,

Smitha,

.... Did this work for you ?

.... Are you using 32 bi excel ? t or 64 bit excel ?

I am using 64 bit Excel, will try this approach and let you know. At a time only 2 Excel Files are being processed and opened simultaneously. Once the processing is complete for the 2 Excel files , the next 2 Files are opened for processing.

On creating a list and Add item to a list getting the below error message Index out of range:

increase %counter_1% by 1

add item %""% to list - *%Excel_A_instance_list[counter_1]**%*

Typing error, the set actions should be set to **-1**, as follows:

set %counter_1% = -1

set %counter_2% = -1

__another typing error, the Add Item to Lists, should be as below__:

add item %""% to list - *%Excel_A_instance_list%*

add item %""% to list - *%Excel_B_instance_list%*

Smitha,

Did it work for you ?

Smitha,

For making it easier to follow, for all, I have made the corrections

below, are all the steps with the revisions.

set %counter_1% = **-1**

Create New List - %Excel_A_instance_list%

set %counter_2% = **-1**

Create New List - %Excel_B_instance_list%

**Loop ..... for each pair set of 2 excel files to open concurrently and process**

*add your code here to Retrieve your next set of 2 excel files to open *

*concurrently and process*

**... Open Excel File A**

increase %counter_1% by 1

add item %""% to list - **%Excel_A_instance_list*** %* (... add empty string as list item )

**Launch Excel File_A**

--- specify excel instance variable: *%Excel_A_instance_list[counter_1]%*

For your __Read Excel actions and Write Excel actions,__

use for Excel Instance: *%Excel_A_instance_list[counter_1]%*

*... Open Excel File B*

increase %counter_2% by 1

add item %""% to list - *% Excel_B_instance_list*

*(... add empty string as list item )*

**%**

Launch Excel File_B

--- specify excel instance

variable: *%Excel_B_instance_list[counter_2]%*

*For your*

use for Excel Instance:

__Read Excel actions and Write Excel actions,__use for Excel Instance:

*%Excel_B_instance_list[counter_2]%*

.... do your processing of set/pair of Excel A and Excel B

( 2 concurrently opened excel instances)

.... Close Excel File_A %Excel_A_instance_list[counter_1]%

.... Close Excel File_B %Excel_B_instance_list[counter_2]%

**End Loop ( looping while pairs of excel files to process )**

Thanks will test it with the changes

Getting an error at this point:

--- specify excel instance variable: *%Excel_A_instance_list[counter_1]%*

*here specifying the %ExcelInstance% to the %Excel_A_instance_list[counter_1]% is throwing error, "Wrong value passed cannot covert Text Value into a List"*

Hi Joseph,

Thanks for the detailed approach that you suggested. Added the below check just before attempting the close the Excel Instance and it is working fine now. The multiple files are getting processed without any error.

Added a check that if Process 'Excel' is running then only attempt the Close Excel Action. It is working fine now.

As per observation, closing the first Excel instance works fine, but it also closes the second Excel instance at times while closing the first instance, hence when attempting the close on the Second Excel instance which does not exist any more was giving the error while closing Excel.

Thanks a lot for your detailed suggestion and followup. Appreciate it.

Smitha,

1) Your line 12, should be deleted.

2) Your line 13, should be as below:

add item %""% to list**%Excel_A_instance_list****%**

## Smitha Shashidharan

Using Process Robot 2020.1.0.3299, Unable to close two Excel Instances which are being used simultaneously. If there are 3 to 4 excel files to process, the Close Excel works fine. But with 11 or more Excel files to process, with two Excel files opened at a time, facing errors while closing Excel Instances.

Any inputs on handling this would be useful