Using custom action to open an Excel file


I see from the documentation that com.workfusion.rpa.helpers provides support for excel file manipulation. Reliably opening files is one issue that I have a problem making work and I would like to make a custom action for this.

Unfortunately I can’t get this to work. Could someone help with writing a simple script to open a file so that I can see the structure of how to use the Custom Action, the existing samples have not really helped me understand how to use this new feature.

All help welcome!

1 Like

Here is a very basic script to open a file and copy cell value.

 def customScript() {

cell_value = RString.of(getCell("path/to/excel/file", "cell/position"))


But it is already implemented in the excel actions we have in the library, and you need to be an experienced developer for more complex excel automation.

What are the issues that you currently have with opening excel files? Is it working unstably?

I do actually have some issues with opening a file when I want to open it without using the excel actions. I usually try to do it using images but it is not reliable, even when I pin the file.

However, I would like to play around with Groovy except that I can’t even get very basic scripts to work so I’m clearly doing something wrong. I couldn’t get your example to run with the following code:

Am I missing some step to get the code to execute?

You should use double backslashes in the path instead of single one.
Sorry, forgot to write about it in my previous post.

Missed that in your message at first.
The script above actually opens Excel in background, too.
Do you need to open the file and be able to use Excel UI?

That’s exactly right. If I want to open an excel file and make some manipulations (such as make calculations and then copy some things back to recorder) then I have problems with reliably opening the file in a persistent Excel instance. The only way I know to do this is using image recognition but I have real difficulty making it work reliably even with the file pinned in explorer.

I would like to make a custom object to open excel and a file path so that I could pass a parameter with the file name and path and be sure it would open on every try. I have made some progress with learning groovy so may get this done myself eventually…but if anybody can help? Well that would be just great!!!

Have you tried opening the file via Win+r? That should be stable as long as the path to the file doesn’t change.

When I try to do that I get the following error:

It does not open the file - I still need to select Excel even with the full path including .xlsx extention and then Excel gives the above error.

Does it happen to all Excel files? Must be excel-related issue.
This should open the file just like via images.

@Bonnero If you want to use custom actions, you can open Excel file like this

def customScript() {
openAndFocus("C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\EXCEL.EXE D:\\file-name.xlsx", 5000, 300)