Do you consider using Excel Application Scope Workbook Output with Close Workbook activity a good practice?

Hi All,

Do you consider using Excel Application Scope Workbook Output with Close Workbook activity a good practice?
Are aware of any risks of not using Close Workbook activity?
Do you think the lack of the Close Workbook might cause a potential HRESULT exception assuming there will be some excel instance left?

Please let me know what are your thoughts and how do you work with Excel.
I will be grateful for your insights.

Best,
Roxy

1 Like

Hi @RoxyPieZu

Welcome to UiPath community

No buddy
Not really
It’s not required to close the file immediately once it is opened with excel application scope
Because by default it will close the file once the data in it is obtained

And if you go by REFramework by default we will be having KILL PROCESS at the END STATE which willl eventually close all the application used in process that includes excel as well

Only if the same excel once after being read is used immediately to write back then it is essentially to kill or close the application

And in order to avoid such scenario or the exception you mentioned, while writing alone use WORKBOOK activities like write range activity because it will not require excel application to be triggered

Cheers

1 Like

Hi @Palaniyappan

many thanks for such a quick response.

Follow-up question:

Did you mean that it makes sense to use Close Workbook activity/Kill Process in case of a need to play with the same Excel file multiple times in a row? Do you know the reason behind this?

Cheers

1 Like

@RoxyPieZu

Setting Cache instance period to 0 is also useful to avoid HRESULT error.

1 Like

Ofcourse
If you are using a excel file repeatedly for multiple tikes one after the another then we will be getting issue in excel service
Or sometimes it will throw an error that excel file is being used by another process
Or HRResult call error

@RoxyPieZu

1 Like

I have messed with these settings multiple times and I have the most success with the workbook activities outside the Excel Application Scope. There is still not enough documentation around what exactly the cache property is.

Regardless I’ve discovered that manipulating an existing Excel file located in a network folder is best handled by copying the file into the local drive of the machine where the robot user is processing. Then all the activities happen within the local copy and then you finally save the file to the existing network file location.

This avoids issues where I am doing several activities such as write cells to a network file path and there is some disconnect where the original file gets deleted and replaced by a blank file that has done the particular write cell activity. I suggest this use case / tip added to the general official documentation since I’ve had to try a multitude of actions before coming to this conclusion such as killing the Excel Process within the machine, disabling the auto save feature in the excel application scope, Using close workbook activity and save workbook activity, adding 2 second delays to each Excel write activity…

1 Like