Error in Excel: "For Each: Object reference not set to an instance of an object."

What is the solution in this kind of error? I tried to change the TypeArgument into String but it didn’t work. Thank you for the help.

@ROBERT_RUSSELL_MONSA

Is TimeSheet variable is of type Workbook or not ?

May I know from where you are getting this value ?

1 Like

Yes.

@ROBERT_RUSSELL_MONSA

May I know what are you checking inside ForEach loop ?

1 Like

Hi
Is that TimeSheet variable mentioned in EXCEL APPLICATION SCOPE along the property WORKBOOK
Kindly check that once
Cheers @ROBERT_RUSSELL_MONSA

1 Like

image

This is my Excel Application Scope.

I’m checking if the sheets between the 2 excel files are the same and find each one of them.

If you are iterating it then why u are using Timeseet , use name …as now from Timesheet.Getsheets each item is in name …

But how can I execute the for each?

As you are iterating all sheets using For Each
So for first iteration First sheet from that excel file will be assign in "name"like wise for second iteration second sheet
You can check it by using Write Line or message box inside For Each
and write name inside it

Hi @ROBERT_RUSSELL_MONSA

Can you show me where you have assigned the data to the TimeSheet variable you created? I see that you are using it in the for each activity, but I don’t see where you have assigned the data to it…

If you are navigating through the sheets in teh excel file, then You can to use the get workbook sheets activity inside excel application scope and assign the output of that to TimeSheet variable. Have you done that?


For Ref

2 Likes

It still didn’t work.

show me your excel application scope properties like i have attached above

3 Likes

Change the TypeArgument of For each to Object.
Send the screenshot of property panel of the Excel Application Scope.

2 Likes

Thank you so much for the help.

Welcome!

Happy Automation :partying_face:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.