WorkBook Read Range: Index was out of range. Must be non-negative and less than the size of the collection.Parameter name: index

The type does not affect the scope. The scope is set based on the activity you have selected when you do the CTRL+K.

1 Like

Thanks. Right, good catch.

Regardless, every variable creation method requires checking
its scope and type in the Variables Panel.

Can you offer any other solutions to the original topic/issue?

Thanks Lcaravel, but i notice this does not works for the issue im having with excel, any other ideas?

Unfortunately, no, I don’t have any other ideas. I still have not fixed my issue. I even recreated the project to see if I missed something along the way or if it would throw the same errors, and at first there were other issues, but then the original one popped back up too.

hopefully this will be fixed with an excel plugin update on uipath, if some of us find a solution please advise

Are there actually items in the MailMessages list? If the count is 0, then MailMessages(0) to retrieve the first item will throw an error because there are no items. Put an If (with condition MailMessages.Count > 0) and put the Save Last Task Mail Attachment into the Then block. You can use the Else block to control what happens if there is nothing in MailMessages, such as Log Message or Terminate Workflow.

I fixed this by going in to the Get Data sequence

click on get outlook mail message activity

check MarkAsRead
uncheck OnlyUnreadMessages

This should fix your problem hector. Please let me know if this works

@Pedro_Estrada
@lcaravel

It was outputting zero until i checked the boxes o mentioned above

You can use make a message box for Mailmessages.count

I think this works for some, but not me, my issue is with excel and uipath, not with mail options.

Please attach screen shot

The error message always means the same thing. You’re referencing an element (index) of an enumerable (datatable, array, etc) that does not exist.

For example, if you have an array with 3 elements, and try to reference theArray(3) you’ll get the index out of range error because theArray(3) would be a 4th element. The first element is index 0.

Hi Postwick, the thing is, that if i remove pivot tables on other sheets from my excel file it works.

1 Like

It sounds like the pivot tables are causing it not to be able to read the sheet(s), and this is resulting in a table with 0 rows. So if you try to access a row via index, even index (0) is out of range. Could also be a column you’re referencing that isn’t there.

1 Like

Choosing the correct scope for the variable: MailMessages is what ultimately resolved my issue.

That said, you & Paul’s posts have helped me with other related issues --Thanks

Removing the Pivot worksheet resolved my problem.
Seems like UiPath workbook activities doesn’t work with the Excel wherever there is a Pivot Table.
Update: If Pivot sheet Present after the sheet which you want to read then activity will work but whenver before the sheet, It will throw the same Exception

Hats off to @Pedro_Estrada and @postwick
@pakankshabha Please mark any of the reply to Solution so that no one needs to scroll till end.

Thanks,
Arpit

2 Likes

Hey any solution for this issue ? I have same issue.

There are multiple solutions presented in the replies

I exactly don’t understand this, Can you please help me ?

I am reading A-E from Excel 1 and Putting in Excel 2.

Note : I don’t have pivot when I am reading excel 1.