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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / if file exists on shar...
Power Automate
Unanswered

if file exists on sharepoint

(1) ShareShare
ReportReport
Posted on by

If file exits action power automate desktop is not working for sharepoint folder

 

I'm trying to save a excel file if the file exists with current month name

 

eg if july file exists then save the excel with same file 

 

July file is already there but not getting replaced .

 

I have the same question (0)
  • Deenuji_Loganathan_ Profile Picture
    6,250 Super User 2025 Season 2 on at

    @kkb19 

     

    How is your flow looks like? Please share some screenshot

     


    Thanks,
    Deenuji Loganathan 👩‍💻
    Automation Evangelist 🤖
    Follow me on LinkedIn 👥

    -------------------------------------------------------------------------------------------------------------
    If I've helped solve your query, kindly mark my response as the solution ✔ and give it a thumbs up!👍 Your feedback supports future seekers 🚀

  • kkb19 Profile Picture
    on at

    To get july-2024 i've used current date and then converted it to text and then used it along with my sharepoint link and .xlsx extension

     

    kkb19_0-1720545688072.pngkkb19_1-1720545696437.png

                                                                                          kkb19_4-1720545845585.png

     

    kkb19_3-1720545736812.pngkkb19_2-1720545722366.png

     

  • Deenuji_Loganathan_ Profile Picture
    6,250 Super User 2025 Season 2 on at

    @kkb19 

     

    Could you please specify the exact error you are encountering at the moment? Additionally, try removing the 'if' condition and attempt to save your Excel file directly to SharePoint to check if it can be saved successfully.

  • Verified answer
    Deenuji_Loganathan_ Profile Picture
    6,250 Super User 2025 Season 2 on at

    @kkb19 

     

    My understanding is that you cannot treat a SharePoint link as a variable to check if a file exists, similar to checking for a local file. SharePoint actions work a bit differently, so consider the following approach:

     

    1. List files from a folder - This will provide a list of all filenames.
    2. Use a 'for each' loop to iterate through the list of files returned by SharePoint.
    3. This will return the file name in the 'currentitem.Name' variable, where you can verify the presence of a targeted file.
    4. Depending on whether the file exists or not, and based on your business rules, create your Excel file accordingly.

     

    Note that you cannot directly save your Excel file in a SharePoint folder. You must first convert the file into binary data, as mentioned in step two, and then use the SharePoint 'create file' action, where you specify the SharePoint URL and other parameters, including the file name and file content (converted binary data).

     

    I hope this is helpful!

     

    Deenuji_1-1720547065128.png

     

    Create file action :

    Deenuji_2-1720547106448.png

     


    Thanks,
    Deenuji Loganathan 👩‍💻
    Automation Evangelist 🤖
    Follow me on LinkedIn 👥

    -------------------------------------------------------------------------------------------------------------
    If I've helped solve your query, kindly mark my response as the solution ✔ and give it a thumbs up!👍 Your feedback supports future seekers 🚀

     

     

  • kkb19 Profile Picture
    on at

    Hi @Deenuji 

     

    Thanks for the above steps.

     

    I dont have access to premium license

     

    I'm able to save the file by adding a shortcut of the sharepoint folder to my one drive and gave reference of that folder, its worked the file in sharepoint is getting updated.

  • kkb19 Profile Picture
    on at

    Hi @Deenuji 

     

    Save Excel option sometimes works fine but some times its failing but the file is getting saved in the sharepoint folder, Run is not ending.

     

    Any solution to this please.

     

    kkb19_0-1720638477174.png

     

    Exception has been thrown by the target of an invocation.: Microsoft.PowerPlatform.PowerAutomate.Desktop.Actions.SDK.ActionException: Failed to save Excel document System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException: SaveAs method of Workbook class failed

       --- 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 Microsoft.Flow.RPA.Desktop.Modules.Excel.Common.Extensions.ExcelHelper.InvokeMethod(Object object, String methodName, Object[] methodArgs)

       at Microsoft.Flow.RPA.Desktop.Modules.Excel.Actions.ExcelActions.SaveExcelInstance(Object activeWorkbook, String workbookName, FileVariant documentPathSafe, SaveExcelEnum saveSafe, ExcelSaveAsFormatEnum saveAsFormatSafe, String xmlMapName)

       at Microsoft.Flow.RPA.Desktop.Modules.Excel.Actions.ExcelActions.SaveExcel(Variant excelInstance, Variant documentPath, Int32 save, Int32 saveAsFormat, String xmlMapName)

       --- End of inner exception stack trace ---

       at Microsoft.Flow.RPA.Desktop.Modules.Excel.Actions.SaveExcel.Execute(ActionContext context)

       at Microsoft.Flow.RPA.Desktop.Robin.Engine.Execution.ActionRunner.Run(IActionStatement statement, Dictionary`2 inputArguments, Dictionary`2 outputArguments)

     

  • Deenuji_Loganathan_ Profile Picture
    6,250 Super User 2025 Season 2 on at

    @kkb19 

     

    I didn't get much clue with error details. But alternatively, write your Excel file to a local drive first instead of saving it directly to a SharePoint folder. Once the file is successfully saved to the local drive, you can then move or copy it to the SharePoint folder.

     


    Thanks,
    Deenuji Loganathan 👩‍💻
    Power Automate Desktop Community Champion 🤖
    Follow me on LinkedIn 👥

    -------------------------------------------------------------------------------------------------------------
    If I've helped solve your query, kindly mark my response as the solution ✔ and give it a thumbs up!👍 Your feedback supports future seekers 🚀

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard