Hello community,
I am working within the ExcelProcessScope and trying to use type into activity to enter some values into the excel sheet. However, I am getting the error below:
This error occured with other activities like Click activity as well. I am getting this error with or without opening the excel file. Can anyone please help with a solution to this error?
Many thanks!
For excel automation there a package available UiPath.Excel.Activities
From this package you can use write cell activity to enter some values in the excel. But doing UI Automation for excel is not recommended. Hope this helps!
Hi @Rahul_Unnikrishnan, @Rounak_Kumar1, @THIRU_NANI and @postwick, many thanks for your responses.
Sorry for the confusion that was generated by my question. What I wanted to achieve is to send keys to the Excel sheet and not actually to type in some values. Here is a simple breakdown of my workflow:
Fetching unstructured text from a website with the Get Text activity
Save the text in a datatable with Generate Data Table activity
Get the last row with text from my excel sheet
Then append this text into an Excel sheet (range LastRow + 1) with the Write Range activity.
This simple workflow works pretty fine. But after testing with lots of input data, there were cases where the text data have duplicate values. So, while saving into the datatable, it would throw an error that the table could not be created because of duplicate column names.
My approach at resolving this therefore is to save the text to clipboard and then try to paste it into the excel sheet with a send hotkey activity. So, I am doing the following:
Use the Select Range activity to the cell I want to paste into
Use send hotkey activity (classic activity without any selector) to send Ctrl + v to paste the text into the selected cell.
But unfortunately, this does not work. I also used Type into activity (Classic) to send “[K(Alt)]”+“h”+“v”+“t” into the excel sheet, and this also did not work. This then led me to using the Type into activity (modern design) and generated the error that I posted in the question. But it is good to know now that UI based automation does not work in Excel.
My other aproach has been to use a VBA script and then pass the range variable as a parameter within the function. This is also not working right now. But I guess I need to look more into the function.
In addition to pasting the text into Excel, I also need to use send keys to send keyboard shortcuts (Alt + H + B + A) to create thick borders around every table in the sheet for readability.
So, my question then is what is the best way to send keys to an Excel sheet if UI based automation is not recommended in Excel?
Write range and Write Cell activities are writing the whole chunk of text into a single cell. For my use case, the text could sometimes be up to 40 rows. Therefore, I need to use a keyboard shortcut to preserve the formatting of the text.
Thank you @Rounak_Kumar1 for this nice suggestion. I thought about this before but I was afraid of the impact on the runtime. I think I will give it a try now. Many thanks.
Hi @Rounak_Kumar1,
Unfortunately, this approach does not also work The text is still being pasted into a single cell.
My workaround solution now is to add a special character to the line that was always creating duplicates in my text data. That way, I can use Generate Data Table activity without any conflict of duplicate column. Then, I am using a Find/Replace activity to remove the special character afterward before saving the output sheet.
However, I still need to know the best approach to send keys in the Excel activity. For example, I need to send keyboard shortcuts (Alt + H + B + A) to create borders around every table in the sheet for readability because I could sometimes have more than 20 different tables in the sheet.
hey,
you can do like that
step 1- Move the text file and change the name from “file.txt” to “file.csv” .
step 2- Read the CSV with delimiter of “TAB” .
step 3-Write the excel back to the .xlsx file(Or any format).
Thanks
Hi @minhle,
I solved my problem by using the classic activities. I tried everything with the Modern design activities and I was not able to select the UI element even with the Excel file already opened.
Just ensure that show classic is checked in the Activities tab, and then, you should see the classic activities.
I have exactly the same issue - i am following the UiPath training (introductory course) and I get stuck here - and cannot continue to follow the demo in my studio instance
Hello everyone. Just going through the course UiPath Academy Course “Excel Automation with the Modern Experience in Studio” and had the same error.
I did find a solution to this, but it may not be replicable:
I just copy pasted the whole project folder from a “One Drive Directory” to a “C:” directory (as my root UiPath directory is located on a OneDrive folder).
Then, I opened the recently moved project on UiPath, opened the “MonthReport” file (the one on the new directory) and clicked on “Indicate in Month Report” It worked!