Close excel file with excel modern activities

Hello,

I’m struggling to find a way to open an excel file in the init workflow, leave it open and then close it at the end, using the excel modern activities.
With the classic ones, I used to create a workbook variable and use as an input of the excel application scope and then use the close workbook activity.
With the modern ones, I can use “Use excel file”, flag the option “keep excel file open” but I don’t find a way to close as I was used before. Do you know why ?

Thanks

Hey! Welcome to community!

Could you please tell me why do we wants to open the excel?

I mean is there any specific reason behind this?

Have a view on this thread

Regards,
NaNi

Because I want to be able to open it in the init and leave it open during the execution and not close it and reopen it everytime, especially when I work with heavy excel files.
I just want to know if there’s an option with the modern excel activities to do what I was used to do with the classic ones.

Thanks

No answers yet ?

Hey!

Have you checked the above mentioned thread?

Regards,
NaNi

Yes and it has nothing to do with my problem, especially because it’s a topic of 2017 so obviously it doesn’t involve the new excel modern activities.
Are you sure you really understood my problem ? I can provide you more information if you need them.
Thanks and regards,

Pier

Hey!

They used Start process and open application… In 2022 we have the same activities…

There will be updates in the activities…

But the Process is same…

Could you please try the mentioned approach…

Regards,
NaNi

I don’t want to use start process and open application because like this I cannot use all the modern excel activities, like autofit, get last row etc etc. I would like to know if there’s a corresponding close workbook activity in the modern excel ones.
Regards,

Pier

Hi @Pier_Filippo_Veneziani,

I would like to know if you have found any solution to close the already opened workbook in modern activities?

Regards,
Noufal

No, no solution yet. Unless @THIRU_NANI has found one, I think I’ll use the classic ones

1 Like

Hi,

Although the following might be not graceful way, it will work.

image

OR

Regards,

@Yoichi Hi, The workaround suggested by you is not available in UiPath latest version.
New WorkbookApplication() is not available instead WorkbookQuickHandle() is available.

Can you please confirm if both are the same or different?

1 Like

Hi! Just stumble on this topic because I have the same problem and I think I found the solution.

Try this, it works for me:

  1. Open your Excel file with the classic ‘Excel application scope’ activity and store it in the workbook variable to keep the file open.

  2. When you need the file use again classic ‘Excel application scope’ activity with the previously created workbook variable

  3. In ‘Do’ section of the classic activity just add modern Excel activity ‘Use excel file’. For path just use the same path which you used to open a file in step 1. It will not open a new Excel process or the same workbook - fun fact :slight_smile:

  4. In ‘Do’ section of modern activity do whatever you need to do :wink:

  5. When you finish, use classic ‘Close workbook’ activity to close file.

I hope this will help someone in the future.

Just my 2 cents , based on the assumption that you have just one Excel process opened at runtime why just not use Kill process ?

Regards,
Dragos.

Kill Process, IMO, is overused and the risks are not often discussed. Force killing an app with a file open in that app can leave apps and files in an unwanted state, corrupt data, etc.

If you have an open app that you want your automation to close, close it the right way - the way a human would. Click the X in the top right and deal with any popups that appear.

1 Like