cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
r96359
Helper IV
Helper IV

Launch Excel using Variable for file name erroring even though Path and File Name are fine.

Hello All,

 

I'm trying to use Launch Excel to open an excel file using a variable for File Name.

Variable "%xlsFile%" = "fileone.xls".

 

So document path is populated as : "C:\Users\me\OneDrive\RPA\TCR\In\Temp attachments\%xlsFile%

 

r96359_0-1619759510865.png

 

Even though the path and file name is correct, I am getting an error as if the path and file name was not correct.

Error is:

 

Robin.Core.ActionException: Failed to open Excel document '(File related error.)' C:\Users\me\OneDrive\RPA\TCR\In\Temp attachments\fileone.xls

 

Here's my version of PAD

r96359_1-1619759730153.png

 

Anyone know what may be causing this?

 

Thanks!

 

Long error below:

 

Robin.Core.ActionException: Failed to open Excel document '(File related error.)' C:\Users\me\OneDrive\RPA\TCR\In\Temp attachments\fileone.xls
. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException: Sorry, we couldn't find C:\Users\me\OneDrive\RPA\TCR\In\Temp attachments\fileone.xls
. Is it possible it was moved, renamed or deleted?
--- End of inner exception stack trace ---
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, CultureInfo culture)
at Robin.Modules.Excel.Actions.ExcelActions.InvokeMethod(Object o, String methodName, Object[] methodArgs)
at Robin.Modules.Excel.Actions.ExcelActions.LaunchExcel(Variant documentPath, Variant varPassword, Variant& excelInstance, Int32 launchMode, Boolean visible, Boolean loadAddInsAndMacros, Boolean needsAuthentication, Boolean readOnly)
--- End of inner exception stack trace ---
at Robin.Modules.Excel.Actions.LaunchExcel.Execute(ActionContext context)
at Robin.Runtime.Engine.ActionRunner.RunAction(String action, Dictionary`2 inputArguments, Dictionary`2 outputArguments, IActionStatement statement)

1 ACCEPTED SOLUTION

Accepted Solutions
r96359
Helper IV
Helper IV

So I didn't fix the issue of why the path wouldn't work in Launch Excel using the variable for file name I was using. Even thought it was writing correctly. I did find out a work around.

 

I was using a loop to look through downloaded attachments from Retrieve email messages from Outlook. l was downloading for excel files only but people send signatures etc that are jpg, png. So I had an xtra loop and if condition to only find xls files. Then write the full path of the xls file to a variable. 

Outside of that xls loop was I was trying to write the launch excel action since I got the value I wanted in the previous loop. PAD didn't like that.

Long story short, I moved the Launch Excel action into the most inner loop that is filtering for excel files and used that variable from the if condition and that it worked!

Another point, Launch Excel took the full variable for path and file name once it was placed within the this loop. 

 

r96359_0-1619797753289.png

 

View solution in original post

8 REPLIES 8
r96359
Helper IV
Helper IV

@CFernandes 

@DamoBird365 

@ScottShearer 

@jinivthakkar 

 

Any ideas on what might be causing this?

 

I do see an odd paragraph return after the file name fileone.xls in the error.

If I use set clipboard text to copy and paste the full value, Notepad++ sees the paragraph return but MS Word doesn't.

 

"Robin.Core.ActionException: Failed to open Excel document '(File related error.)' C:\Users\me\OneDrive\RPA\TCR\In\Temp attachments\fileone.xls
. --->"

 

Any reason why that is happening or how to remove it?

This might be what is causing the issue.

 

Much appreciated!

CFernandes
Super User
Super User

Hello @r96359 ,,

 

Can you please confirm that the problem is specific to the file? 

 

The error "Failed to open Excel document '(File related error.)" is caused when the file has a corrupt add-in in the program or when your excel program may be conflicting in some way with another program. A file in the Excel startup folder may have some problems.

 

Can you repair you Office application and try again?

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Henrik_M
Dual Super User
Dual Super User

Try to change the input:

C:\Users\me\OneDrive\RPA\TCR\In\Temp attachments\\%xlsFile% (two backslashes at the end)

@CFernandes Thanks for the reply! Xls isn't corrupt. Opens fine outside of PAD using the same URL.

@Henrik_M Thanks for the reply! I tried that and I got the same error.

 

Robin.Core.ActionException: Failed to open Excel document '(File related error.)' C:\Users\me\OneDrive\RPA\TCR\In\Temp attachments\\fileone.xls

r96359
Helper IV
Helper IV

So I didn't fix the issue of why the path wouldn't work in Launch Excel using the variable for file name I was using. Even thought it was writing correctly. I did find out a work around.

 

I was using a loop to look through downloaded attachments from Retrieve email messages from Outlook. l was downloading for excel files only but people send signatures etc that are jpg, png. So I had an xtra loop and if condition to only find xls files. Then write the full path of the xls file to a variable. 

Outside of that xls loop was I was trying to write the launch excel action since I got the value I wanted in the previous loop. PAD didn't like that.

Long story short, I moved the Launch Excel action into the most inner loop that is filtering for excel files and used that variable from the if condition and that it worked!

Another point, Launch Excel took the full variable for path and file name once it was placed within the this loop. 

 

r96359_0-1619797753289.png

 

I am facing the same issue where launching the excel using variable get fails

I as well am facing the same issue.

Helpful resources

Announcements
MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

New Process Advisor Capabilities carousel.png

Read the blog for the latest news

Read the latest about new experiences and capabilities in the Power Automate product blog.

PA Survey Carousel Image.png

We want to hear from you!

If you are a small business ISV/Reseller, share your thoughts with our research team.

AI Builder AMA June 7th carousel (up on May 25th, take down June 8th) (1).png

'Ask Microsoft Anything' about AI Builder!

The AI Builder team invite you to ask questions and provide helpful answers at our next AMA.

Users online (1,534)