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 / Generate a flow to cop...
Power Automate
Answered

Generate a flow to copy values from excel rows and paste it in word document as new line

(0) ShareShare
ReportReport
Posted on by 36

Hi,

 

I do have an excel sheet contains values in multiple rows and 6 columns as shown below.

Madhavaraja_1-1678972188582.png

 

Is there any way we can create a flow to copy values from excel rows and paste it in word document as new line?

Madhavaraja_0-1678972117062.png

Thanks in Advance.

MR.

I have the same question (0)
  • AS-06081019-0 Profile Picture
    1,738 Super User 2024 Season 1 on at

    Try using Power automate cloud instead, if you can.

  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @Madhavaraja 

     

    To try in power automate desktop, you have to utilize the powershell script as well

     

    Use this code

     

     

    SET doc_file TO $'''%''%'''
    SET excel TO $'''%''%'''
    Excel.LaunchExcel.LaunchAndOpenUnderExistingProcess Path: excel Visible: True ReadOnly: False Instance=> ExcelInstance
    Excel.GetFirstFreeColumnRow Instance: ExcelInstance FirstFreeColumn=> FirstFreeColumn FirstFreeRow=> FirstFreeRow
    Excel.ReadFromExcel.ReadCells Instance: ExcelInstance StartColumn: $'''A''' StartRow: 1 EndColumn: FirstFreeColumn - 1 EndRow: FirstFreeRow - 1 ReadAsText: False FirstLineIsHeader: False RangeValue=> ExcelData
    Excel.CloseExcel.Close Instance: ExcelInstance
    SET Final_String TO $'''%''%'''
    Variables.CreateNewList List=> final_list
    LOOP FOREACH row IN ExcelData
    SET Final_String TO $'''\"%row[0]%\" +\" \"+ \"%row[1]%\"+\"`n\"+ \"a. %row[2]%\"+\"`n\"+\"b. %row[3]%\"+\"`n\"+\"c. %row[4]%\"'''
    Variables.AddItemToList Item: Final_String List: final_list
    END
    Text.JoinText.JoinWithCustomDelimiter List: final_list CustomDelimiter: $'''+\"`n\"+\"`n\"+''' Result=> JoinedText
    Scripting.RunPowershellScript Script: $'''# Create a new Word application object
    $word = New-Object -ComObject Word.Application

    # Make Word visible
    $word.Visible = $true

    # Create a new document
    $doc = $word.Documents.Add()

    # Get the content range of the document
    $content = $doc.Content

    # Write data to the document
    $content.Text = %JoinedText%

    # Save the document
    $doc.SaveAs(\"%doc_file%\")

    # Close the document
    $doc.Close()

    # Quit Word
    $word.Quit()''' ScriptOutput=> PowershellOutput ScriptError=> ScriptError

     

     

    specify the doc_file variable with word document path, excel variable with excel file path.

     

    Results

     

    Input excel 

    Nived_Nambiar_0-1678990644315.png

     

     

    Output word file

     

    Nived_Nambiar_1-1678990666275.png

     

     

     

    If this answer helped you, Kindly mark this as solution so that others can be benifited.

     

    Thanks & Regards,

    Nived N

     

     

  • Madhavaraja Profile Picture
    36 on at

    Hi,

     

    Tried the above script and got error as below mentioned.

     

    Parameter 'Powershell code to run':Variable 'row' doesn't exist.

  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @Madhavaraja 

     

    Just copy the copy and open the power automate workflow and use ctrl +v to paste it. It will paste the complete flow

    The changes you have to make one is added the excel file and other document path, that's all needed 🙂

     

  • Madhavaraja Profile Picture
    36 on at

    Tried and still getting the error in line-10.

     

    Also check the file location details mentioned is correct

     

    Madhavaraja_0-1679725574572.png

     

    Capture.JPG
  • Verified answer
    Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    @Madhavaraja 

    Not sure why you are getting loop part like that while copying, But i am getting correct flow 

     

    Below is the flow screenshot, you can refer this

     

    Nived_Nambiar_0-1679726120915.png

     

    Nived_Nambiar_1-1679726133329.png

     

     

    Power shell script

     

     

    # Create a new Word application object
    $word = New-Object -ComObject Word.Application

    # Make Word visible
    $word.Visible = $true

    # Create a new document
    $doc = $word.Documents.Add()

    # Get the content range of the document
    $content = $doc.Content

    # Write data to the document
    $content.Text = %JoinedText%

    # Save the document
    $doc.SaveAs("%doc_file%")

    # Close the document
    $doc.Close()

    # Quit Word
    $word.Quit()

     

     

     

    Hope this helps 🙂

     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 1,005

#2
Valantis Profile Picture

Valantis 825

#3
Haque Profile Picture

Haque 619

Last 30 days Overall leaderboard