Error: "Assign: Object reference not set to an instance of an object"

Hi, so basically I want to loop through every sheet that exists in a workbook. Then, I found this specific solution: How to get the Sheet name from Excel - #31 by PrankurJoshi

When I tried that solution and run it, it works okay, but when I make it from scratch, using the same step-by-step activities used in the solution file, I got this error “Assign: Object reference not set to an instance of an object” and I could not figure out why cause I literally just follow every single activity there.

And yes, I have added the Sheets and workbook variables.

@marsaandari

You got this error because the expression you used in right hand side of assign activity gives Null value. Can you please run the process in Debug mode and check values are coming properly or not.

Hi

The main reason for that error is the object is having null value that’s why

Check whether workbook variable is within scope
For that go to variable panel and for the variable you have obtained from excel application scope check with the scope column and keep to the last value that is whole sequence itself

Then this error won’t come

Or

May be i will try to reframe it with steps and hope would meet your requirements
Which doesn’t have any assign activity and uses minimal activities to achieve this

  1. Use a excel application scope and pass the file path as input
    And get the output from the excel application scope activity itself as a variable named out_workbook

  2. Inside that excel application scope use a FOR EACH activity where mention the input as
    Out_workbook.GetSheets and change the type argument as string in for each activity

  3. Inside the loop use a write line activity like this
    Item.ToString

This will print the sheetname in output panel one by one

Or to be very simple we can use GET WORKBOOK SHEETS activity

Cheers @marsaandari

Hi @Palaniyappan

Thanks!!

1 Like

Glad

Happy automation @marsaandari

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