Error - Read Range Workbook: Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection. (Parameter 'count')

Hi,

Using the “Read Range Workbook” activity without defining the range. Basically the process reads a spreadsheet for “Open” records and adds them to the orchestrator queue to be processed. This runs fine, the problem is that at the end of the process when it goes back to read the workbook and change the “Open” to “Closed” it causes an error:

“Read Range Workbook: Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection. (Parameter ‘count’)”

I don’t understand why this issue is happening as there is no range set. It just reads the entire spreadsheet. This only happens if there are “Open” records further up the list. If there is just one “Open” record then it runs fine. I’ve tried a try/catch to use excel activities if the “Read Range Workbook” creates an error, but using the proper excel activities presents an issue as it’s slower, and also requires a specific range which doesn’t work as the excel spreadsheet can become quite long (800+).

Can anyone suggest why this error is happening and how I could get around it? I’ve tried googling online but none of the other topics seem to match my specific issue.
An RPA workflow in UiPath is shown, featuring a Try Catch block with a Sequence and an Excel Process Scope containing a Read Range Workbook activity. (Captioned by AI)

@charles.bain

First think workbook activities need not be in excel process scope

cheers

The error happens regardless of whether it’s in the Excel process scope. That was my attempt at a fix. I have another read-range activity elsewhere in the process that has also begun throwing the same error and isn’t inside an Excel scope.

I have “solved” the problem with a try/catch that uses modern activities and a defined range to read, but this could cause problems in the future if the team I am building this for do not regularly cleanse the spreadsheet being targeted.

@charles.bain

  1. try giving only start range and check instead of empty
  2. Alternately try to kill excel before reading

cheers

If I understood you correctly, the solution is very simple.

  • Read the excel file into a datatable - you’ve done this already
  • Iterate through the DT and change the “Open” to “Closed”
  • Create a backup copy of the original excel file
  • Now use DT and a Write Range Workbook activity and overwrite the original excel file

Had to use a workaround rather than a fix. Essentially a try/catch activity containing the old read-range activity, then the modern excel activities with a defined range.

This isn’t an ideal fix as the team will have to regularly cleanse the spreadsheet that the bot is reading, but it prevents errors in the process at least.