Error: Object reference not set to an instance of an object. This error usually occurs when using a variable with no set value (not initialized)

This means that there is no data in the table or it has not been initialized before writing into the excel. Do make sure that you have data in datatable

3 Likes

In my case, when there is no data in the datatable then it should return back successfully. But still it is throwing the error while returning back. How to solve this?

Write a check if DataTable.Rows.Count>0 then only it should proceed

1 Like

Hi Guys I have a simple workflow read the excel and write to an excel. Read excel sequence works fine. But write range gives error. Im attaching .xaml file please suggestReadandWriteExcel.xaml (12.0 KB)

1 Like

I am facing the same error in my EmailAutomation workflow.
Main has thrown an exception

Source: If

Message: Object reference not set to an instance of an object. This error usually occurs when using a variable with no set value (not initialized).

Exception Type: NullReferenceException

System.NullReferenceException: Object reference not set to an instance of an object.
at lambda_method(Closure , ActivityContext )
at Microsoft.VisualBasic.Activities.VisualBasicValue1.Execute(CodeActivityContext context) at System.Activities.CodeActivity1.InternalExecuteInResolutionContext(CodeActivityContext context)
at System.Activities.Runtime.ActivityExecutor.ExecuteInResolutionContext[T](ActivityInstance parentInstance, Activity1 expressionActivity) at System.Activities.InArgument1.TryPopulateValue(LocationEnvironment targetEnvironment, ActivityInstance activityInstance, ActivityExecutor executor)
at System.Activities.RuntimeArgument.TryPopulateValue(LocationEnvironment targetEnvironment, ActivityInstance targetActivityInstance, ActivityExecutor executor, Object argumentValueOverride, Location resultLocation, Boolean skipFastPath)
at System.Activities.ActivityInstance.InternalTryPopulateArgumentValueOrScheduleExpression(RuntimeArgument argument, Int32 nextArgumentIndex, ActivityExecutor executor, IDictionary2 argumentValueOverrides, Location resultLocation, Boolean isDynamicUpdate) at System.Activities.ActivityInstance.ResolveArguments(ActivityExecutor executor, IDictionary2 argumentValueOverrides, Location resultLocation, Int32 startIndex)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)


Please check and tell me some solution. I have tried all the suggestion given here.

2 Likes

Hi @sup_93

One of the variables you use in the IF condition is not declared. Please make sure your collection is not empty and the variable Sender is initialized.

1 Like

Hey you are using datatable variable name twice with the same name, delete one and run the workflow it will work

Regards,
Pavan H.

2 Likes

Hi, this might help you :slight_smile:

I scrapped data from this link= https://vivoipl2019schedule.co.in/
Wrote to excel using excel application scope with writerange.
DataScrappingExample.zip (18.6 KB)

Regards,
Pavan H

2 Likes

Sir, I have to extract data from pdf file and put it into excel file. Please help me to overcome my errors.

didn’t get it can you please send the screenshot

Hi @jimmy_jos1
Make Sure Extracted Output Data Table name and Write range Input Data Table name are same

Hi @meenuknd100
What is the issue your are facing?
Please be little more informative :slight_smile:

Thank you for your response

My task is to automate the resume automation:
So I made a rough flow chart:
Firstly Extracted the resume through mail into pdf form- This step is successfully done by me
Second Step: I got the resume pdf now I want some specific variables like Name, Phone, Mail, Address, Education, Experience. For that I installed the package pdf to excel then I upload the pdf. In the property of Pdf to Excel Activity, there was not “Keywords” option from which variables will be extracted. Although I tried alternative of this (Generate the datatable) but from this I got all the resume in Excel not with some specific variables.
Then I thought this was due to community edition problem. So I moved for the Enterprise Edition. But I faced the problem in installation of this edition. We mailed to UiPath for this, they sent us a license activation key. When we use that key we got the error. We tried different mail then again got the same key and same error, and error was Subscription expired.
I am attaching screenshots of my problem which I am facing during this task.Main issues are:
First issue:
I want to extract some specific variables from pdf and want to import in excel sheet for that I installed the package pdf to excel…but in this activity I didn’t get the “Keyword” property, from that I can’t extract specific variables.Second issue:
For the improvement I want to install the enterprise edition , but I was unsuccessful attempt. I use the license key 386787077638800742, after applying this I got the error- Subscription expired.

Hi @yjkim now I’m facing the same issue can you help me how to resolve it

Working with generic.
Changed the variable type to generic.

The error has raised due to the initialization issue of some variable. You can spot the variable first that has been causing issue and then set some default values to that particular variable. Also try changing the variable type to generic.