How to paste data in excel from the clipboard


I am trying to paste data from the clipboard into an excel file. Get From Clipboard works perfectly fine when i copy string data and write it into notepad but when i am trying to get from clipboard and store the data in data-table variable and use write range activity, it gives me an error as “Object reference set to an instance …”.

Can you please help me with this…?

I recommend you open both Excel files. Send hotkey (Ctrl+A) , (Ctrl+C) on the first file. Then (Ctrl+V) on the second file.


Okay, but how can i open excel file ?

Ensure MS Excel is installed on your machine & Use Excel Application Scope Activity. With the ‘visible’ property checked. This will open the excel. Within the Excel Application Scope Activity use the activities I mentioned.


This does not paste the data. I have done exactly same. Do you have any sample for this?
Thank you

@Inzmamul_Haq Can you Show us How were you Assigning the Output of ClipBoard to a Datatable Variabe?

Hi ,

You can try to fetch values one by one and use GET FROM CLIPBOARD activity and then store that in a variable of type string.

Use string variable to store output result in “Get From Clipboard” activity.
Use excel application scope to open the excel file in which you want to paste data by providing the complete path of excel file.
Inside Do use write cell activity and provide sheet name and cell value where you want to paste the data.
In value property give the string variable name given earlier.

@Inzmamul_Haq, This error suggest that your Datatable variable is null. I believe problem is not with getting data from clipboad. Rather problem is with value assignment. Usually you get this error while accessing property of null variable.


Can you please share the workflow file?

Copy Paste.xaml (5.8 KB)

Please find the same

Data table variable has data. Can there be any other reason as well?

Please find below observations-

  1. You are using Get from clipboard activity and assigned the output in a variable named, ClipboardValue. The output for this activity will be of type OutArgument. But the variable ClipboardValue is a datatable variable. This will throw exception
  2. So the flow that you have to write is,
    a. Get data from clipboard and assign it to string variable, ClipboardValue.
    b. Manipulate the ClipboardValue variable to generate a data table.
    c. Use write range to write the value in the excel file.

According to the workflow you sent, your datatable variable will not have any data.

@Inzmamul_Haq Check this Workflow :
Copy Paste.xaml (5.8 KB)

I guess this is what you wanted to Perform,
But if you’re Trying to Copy a Datatable using Ctrl+C and Trying to Get it as a Datatable in UiPath, I’m afraid that is not the way to do it. There are methods Like Data Scraping if you’re Looking for that kind of Solution.

And Please take into consideration what @Madhavi has described

1 Like

Sorry not allowed to upload data.

It is working actually but this data is not in column row format. How do i get it in that format?

@Inzmamul_Haq Can you show us what is the Data in ClipBoard?

@Inzmamul_Haq Yes, That Appears in that way, Is there any Specific reason you’re using Get From ClipboardActivity?, If you’re trying to Copy the Data in one File to another Excel File, There are simpler methods to be used Instead of Performing a Copy Paste.

You can Read the Data using Read Range Activity, Get Output as Datatable
Write that Datatable to a New File using Write Range Activtiy

Yes, i am getting this data in clipboard, data generated by other application. other options to get data from the application, are more complex and hard to find. However, i wanted to point out here that when i paste the in a blank excel it gives me data exactly how i want, i mean in row column format