Error in Writing in an excel file

Hello friends,
@rkelchuri, @Rammohan91, @loginerror,
in my process I should write the output of each transaction item in an Excel file.
I use the activity “Write Range” in Workbook folder.
While processing the second row, I get the error:
SetTransactionStatus.xaml failed: The process cannot access the file ‘----momentaneo.xlsx’ because it is being used by another process. at Source: mscorlib.
CAn you please help me in doing this?
Thank you.
It’s urgent.
CAmilla.

Hi Camilla,

Please try “Write Range” activity inside an excel application scope from ‘App Integration->Excel’, instead of ‘Workbook Write Range’.

Regards,
Nimin

1 Like

Thank you so much @nimin.
I’ve tried it and it works.
The problem is that it creates a BLANK sheet which is not useful.
I shoul delete it.
How can I do that?
Thank you so much,
Cami :slight_smile:

Hi Camilla,

Sorry, I can’t understand your problem exactly. Are you getting the desired output in the excel file?
Are you sure the source excel file don’t have such a blank sheet?
Could you please provide with some more details regarding this issue? :slightly_smiling_face:

Regards,
Nimin

1 Like

Thank you @nimin.
I’m getting the correct output.
The file is created at the beginning of the flow and it doesn’t contain a blank sheet.
Can I delete this sheet at the end of the workflow?
Thank you,
Cami

Hii Cami,

Yes. You can delete it by sending hotkeys.
Use ‘Ctrl+Page Down’ to go to the second sheet and ‘ALT+E+L’ to remove the sheet.

Best Regards,
Nimin

1 Like

Using the excel write range will indeed keep Sheet1. Workarounds are 1). write range to sheet1, then rename it to the appropriate sheet name, 2). delete sheet1 after using write range, or 3). Use workbook write range instead.

The reason you are getting the error is because the robot is working too fast. I’d recommend keeping workbook write range, but surround it with a retry loop. Have it try 3-5 times, waiting 1 second in between each retry interval. This should solve the problem

2 Likes

Hello @Dave
thank you so much for your suggestion.
Can you please share some screenshots or an example of workflow of how to keep workbook write range, but surround it with a retry loop?
Thank yuou so much,
Camilla :slight_smile:

Thank you so much @nimin.
I’ll try your solution and let you know as soon as possible.
Camilla :slight_smile:

1 Like

See Below. The condition can activity can be left blank - it will retry if an error occurs when you leave that portion of the activity blank.

1 Like

Thank you so much @Dave.
I’ll try and let you know as soon as possible.
Camilla :slight_smile:

Hello @Dave,
unfortunately this method doesn’t work.
How can I do?
Sorry for the disturb.
You would help me so much.
CAmilla.

Are you getting the same ‘file in use’ error?

If so, you could surround the write range with a try-catch (all within the retry scope still). The try will just have write range. In the catch, do the generic system.exception and kill process “excel”, then rethrow the error.

Verify that the changes are still made correctly, but that should solve the issue.

1 Like

Thank you so much @Dave.
I’ll try this option and let you know as soon as possible.
Camilla:grinning: