web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Launch Excel using Var...
Power Automate
Answered

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

(0) ShareShare
ReportReport
Posted on by 228

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)

I have the same question (0)
  • r96359 Profile Picture
    228 on at

    @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 Profile Picture
    8,504 Most Valuable Professional on at

    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 Profile Picture
    2,021 Super User 2024 Season 1 on at

    Try to change the input:

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

  • r96359 Profile Picture
    228 on at

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

  • r96359 Profile Picture
    228 on at

    @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

  • Verified answer
    r96359 Profile Picture
    228 on at

    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

     

  • amamidwar23 Profile Picture
    62 on at

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

  • PapaOssis Profile Picture
    12 on at

    I as well am facing the same issue.

  • RiderHarrison69 Profile Picture
    2 on at

    I was facing a similar issue and solved it by using the "trim text" function. The variable I was producing had either a space or a newline in it.

    RiderHarrison69_0-1689709537449.png

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 252 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 169

#3
Haque Profile Picture

Haque 154

Last 30 days Overall leaderboard