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 / Saving multiple Excel ...
Power Automate
Answered

Saving multiple Excel instances

(0) ShareShare
ReportReport
Posted on by 41

Hello, I'm trying to learn how to extract data, inserting it in different Excel instances, saving them, and then pasting all the contents in one same file (different worksheets). However, this happens:

Captura de pantalla 2024-02-11 120642.png
Captura de pantalla 2024-02-11 120442.png

Even if I set "Nombres a colocar" as a list (the names of the files), in each of the "loops", apprently it tries to save it as a full name, and surely that gives an error from the Excel side. What should I do? Thanks!

 

  • Verified answer
    WillSG Profile Picture
    352 Moderator on at

    Hi @Gonza1  I hope you are doing well.

     

    The problem that I’m seeing is that the variable %FileContents2% is a list and you are using this list to save the Excel File, for this reason the error is showing the whole list of archivos.

     

    You need to use a For each Action into another For Each Action to solve this, and into the second for each you need to delete the first item of the list and then exit the second loop.

     

    Here is the snipped code:

     

    File.ReadTextFromFile.ReadTextAsList File: $'''D:\\User\\wsanchez\\Course RPA\\Read From TXT Notepad\\Robot TEST 2.txt''' Encoding: File.TextFileEncoding.UTF8 Contents=> FileContents

    File.ReadTextFromFile.ReadTextAsList File: $'''D:\\User\\wsanchez\\Course RPA\\Read From TXT Notepad\\Robot TEST.txt''' Encoding: File.TextFileEncoding.UTF8 Contents=> FileContents2

    LOOP FOREACH CurrentItem IN FileContents

        WebAutomation.LaunchChrome.LaunchChrome Url: CurrentItem WindowState: WebAutomation.BrowserWindowState.Normal ClearCache: False ClearCookies: False WaitForPageToLoadTimeout: 60 Timeout: 60 BrowserInstance=> Browser

        WebAutomation.ExtractData.ExtractListInExcel BrowserInstance: Browser Control: $'''html > body > div:eq(2) > div > header > div:eq(4) > div > div:eq(4) > table > tbody > tr:eq(0) > td''' ExtractionParameters: {[$'''''', $'''Own Text''', $''''''] } PostProcessData: False TimeoutInSeconds: 60 ExcelInstance=> ExcelInstance

        WebAutomation.CloseWebBrowser BrowserInstance: Browser

        LOOP FOREACH CurrentItem2 IN FileContents2

            Display.ShowMessageDialog.ShowMessage Message: CurrentItem2 Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: True ButtonPressed=> ButtonPressed2

            Excel.ResizeColumnsOrRows.AutofitAllColumns Instance: ExcelInstance

            Excel.SaveExcel.SaveAs Instance: ExcelInstance DocumentFormat: Excel.ExcelFormat.FromExtension DocumentPath: $'''D:\\User\\wsanchez\\Course RPA\\Read From TXT Notepad\\%CurrentItem2%'''

            Excel.CloseExcel.Close Instance: ExcelInstance

            Variables.RemoveItemFromList.RemoveItemFromListByIndex ItemIndex: 0 List: FileContents2

            EXIT LOOP

        END

    END

     

    Also check the image at the end.

     

     

    Please let me know if it works, happy automation!,


    If I have addressed your inquiry successfully, kindly consider marking my response as the preferred solution. If you found my assistance helpful, a 'Thumbs Up' would be greatly appreciated.

     

    Additionally, I offer specialized consultancy and development services leveraging PAD. If you're interested in exploring these services further, feel free to DM me, and we can initiate a discussion.

     

    Kind regards,

     

    Will SG

    Managing Director & Automation Lead

    RAMS CR (Recruitment & Automation)

    LinkedIn Profile

     

    WillSG_Screenshot 2024-02-13 005013.png

  • Gonza1 Profile Picture
    41 on at

    In the end, I made it so it copies all the contents to a new Excel, and manually do it again to the one that has all the information! This one is solved

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

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 424

#2
11manish Profile Picture

11manish 328 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 274

Last 30 days Overall leaderboard