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 / ui-element at a window...
Power Automate
Unanswered

ui-element at a window not working

(1) ShareShare
ReportReport
Posted on by 11

hi guys, I have to program a flow wich has to open an excel worksheet and take some info from there. the problem is that it has to be done everyday from a different excel (example: today tha data has to be taked from "excelworksheet_04_07_2024") 

 

i must use clics for the flow and when i program a clic with UI-element in the window, the action works just today, the next days it comes an error because the flow is working on another excelworksheet.  how can i do it for every day?

I have the same question (0)
  • VishnuReddy1997 Profile Picture
    2,656 Super User 2025 Season 2 on at

    Hi @Redi0ck ,

     

    For excel flow, why your using UI elements actions just try with excel action.

    To open and excel ,launch and read some data from that you can try the below approach as shown in below image.

    VishnuReddy1997_0-1720098418500.png

     

    Code:

    Please copy this code to your flow.

    Folder.GetFiles Folder: $'''C:\\Users\\OneDrive\\Desktop\\Power Automate Desktop\\Practice\\Excel\\Input''' FileFilter: $'''*''' IncludeSubfolders: False FailOnAccessDenied: True SortBy1: Folder.SortBy.NoSort SortDescending1: False SortBy2: Folder.SortBy.NoSort SortDescending2: False SortBy3: Folder.SortBy.NoSort SortDescending3: False Files=> Excel_Files
    Excel.LaunchExcel.LaunchAndOpenUnderExistingProcess Path: CurrentItem_ExcelFile.FullName Visible: True ReadOnly: False Instance=> Input_ExcelInstance
    Excel.ReadFromExcel.ReadAllCells Instance: Input_ExcelInstance ReadAsText: False FirstLineIsHeader: True RangeValue=> ExcelData
    Excel.CloseExcel.Close Instance: Input_ExcelInstance

     

    (Note:- if you got your solution you can mark as solution and gives kudos)


    Thanks & Regards

    Vishnu Reddy

     

  • Verified answer
    mathiaskjeldsen Profile Picture
    224 on at

    Hey @Redi0ck.

     

    I would approach it a little bit different. I'm assuming that the files in the folder are all called a standard thing like "excelworksheet_04_07_2024", so tomorrows file will be called "excelworksheet_05_07_2024". If that's the case, I would create a variable that captures this and then launch excel based on that variable name.

     

    In my example I've gotten the current date and time and transformed it into dd_MM_yyyy to use in my variable setting. In the Launch Excel action you can use this variable by referencing the folder, and then referencing the variable you've created based on the date and some standard name. Please see attached. Let me know if this works.

     

    If this has solved your problem, please mark it as the Solution to help future viewers.

  • mathiaskjeldsen Profile Picture
    224 on at

    Hi @Redi0ck

     

    I have made a walkthrough of your question here, explaining my steps in detail if still needed. 

    Automate Excel File Opening with Date-Driven Flows in Power Automate Desktop

     

    If this solved your problem, please mark it as Solution.

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    This is absolutely the recommended approach, and kudos to you for taking the time to also record the whole thing.

     

    However, @Redi0ck mentioned using UI automation there, but not really clear why. In most Excel-related cases, UI automation is absolutely unnecessary (and very much not recommended). So, if you could please explain what you are trying to do with the file, we may suggest better ways to do the same without the need for UI automation.

  • Redi0ck Profile Picture
    11 on at

    Well, since many people ask why I use UI functions, here is the explanation. What I need to do in Power Automate is update an Excel file that is stored in my company's cloud. For that, I need to extract data from an Excel file that I receive every day (e.g., excel_09_07_2024) and add it to the cloud Excel file. Additionally, I need to add screenshots of a specific page from the company website to the Excel file. The problem is that this cloud Excel file can only be opened on a web page, so the functions for Excel do not work, or at least they have been failing for me. Moreover, there are no predefined actions to add images to an Excel file (especially one opened in the web browser), so I have to use UI clicks.

    Anyway, I have everything programmed and it works fine except for two issues. The first is that I use the "Open Excel" function to open the Excel file I receive daily (which is downloaded to my computer), but inside, I cannot use some UI elements I need to switch worksheets since these are assigned to a specific Excel file and do not work with the next day's file. The other problem is that for the screenshots, for some reason, the capture sometimes fails for some of them. I have no idea why, as it is always the same page.

    I hope I explained myself well, and I hope you can help me.

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

    @Redi0ck 

     

    Could you please provide a screenshot of your desktop flow and an Excel sample file with the image attached? This would enable us to thoroughly understand your issue and offer you the appropriate assistance.

     


    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 🚀

  • Redi0ck Profile Picture
    11 on at

    Well guys, the main problem has been solved, thank you all very much for the help. However, I still have the issue with the screenshots. The problem is as follows:

    I have to take screenshots of a company page that updates information daily. Don't ask me why a screenshot and not another function; I'm just an intern, and my boss wants things done this way. The thing is, I need to take a total of 6 screenshots, and all of them work wonderfully except for two. These two fail every day, and when I reselect the UI of the web page area I want as an image (the same UI I select every day), it works without any problems. However, the next day I have the same problem again; I receive an error from the flow saying that the screenshot could not be taken. Why do the same 2 out of 6 always fail? This didn't happen before. It started failing a couple of days ago, and I can't seem to solve it.

  • mathiaskjeldsen Profile Picture
    224 on at

    Any chance that the UI you select changes from day to day and that's why it fails? Sounds odd I know, but could be? Could you maybe select a UI element right next to it that would work as well? Or are you only grabbing a screenshot of the UI element itself?

  • Redi0ck Profile Picture
    11 on at

    yes, it changes every day. but all the 6 images change every day, so i don't undertand why just that one has this problem

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    It is likely that the element selector for the UI element actually changes, and not just the data.

    Try reading about that here: https://learn.microsoft.com/en-us/power-automate/desktop-flows/build-custom-selectors?wt.mc_id=MVP_307182

    Also watch this video: https://www.youtube.com/watch?v=2PcyBa22Jj8&ab_channel=Thomas%22Shaky%22Petersen

     

    Maybe this will help you figure it out.

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 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard