Excel Application Scope Activity for each sheet: Object reference not set to an instance of an object.
Basically it occurs in UiPath when you are trying to access or manipulate an object that has not been initialized or it empty…
Can you debug and check
@jdsrobot
Welcome to the community
- Are you using any variables in for each sheet? …
- did you give the excel handle properly?
- Are there any other variables you are using?
- Is the excel present already?
- Is the activity used inside use excel file?
Cheers
Hi @jdsrobot
This error generally occurs when the value is null. Run your process in Debug Mode by clicking Step into and Check. Make sure that the Sheet in the Excel and sheet you are using in For Each activity are same.
Regards
If u r passing any variable to the excel application scope check whether it has any value
troubleshooting steps
Click on the excel application scope → Go to debug tab → click on breakpoint
Now run in debug mode so that bot will stop in excel application scope
check with local panels whether there is any value or not in the variable been passed to excel application scope
Hope this helps
Cheers @jdsrobot
Thank you for your responses. I just do not seem to get it. I built this activity exactly like in the video. Double, triple checked everything.
RetrievedEmails.Attachments.First.Name isn’t correct. You need to read the emails into RetrievedEmails, then loop through the emails array (which it looks like you’re doing) and within each use the Save Attachments activity. That activity will return an array of the attachments which you then loop through and use as the path and filename of the Excel Application Scope.
As u r directly trying to get the attachment name it might fail as that specific retrieved mail may not have any attachments in it
So first check whether the retrieved mail has any attachment in it and then try to read it with excel application scope
Use a IF activity like this
RetrivedMails.Attachements.Any
If true it goes to then block there use this excel application scope to read that file
Hope this helps
Cheers @jdsrobot
As per screenshot one possible reason we can see for failure is missing attachment or missing email…
I hope retreivedEmails is list of mails which would be the output of get mails
Is any email retreived? Check using RetreivedEmail.Count>0
then for attachment check using retreivedEmails(0).Attachments.Count>0
Cheers