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 / Entering the data from...
Power Automate
Answered

Entering the data from more than 1 excel files in to sql server & MS Teams action

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello ,

  1. I need to store data from the excel files into MS SQL in the desktop flow. As I have seen actions or in the desktop recordings which opens only 1 excel file , as we need to mention the specific single excel file path. 

But in this scenario, I'll be getting more than 1 excel files to store the data, so I have a cloud flow which automates the process of storing the file in a specific folder & then using the desktop flow I want to give the folder path containing these excel files , so it stores the data to SQL, one excel file after another file's data(until all the files turn is completed).

 

     2. Also after the data entry completion in SQL, there will be a filtering on these data & send again an final copy of file on MS Teams to specific teams. So couldn't find any actions of MS Teams in the app. So how this can be automated using desktop flows.

 

Kindly mention ways of doing this & it's feasibility.

 

 

 

  • MichaelAnnis Profile Picture
    5,727 Moderator on at

    Definitely feasible.

     

    I am not sure about the SQL part, but you can build a larger Excel file out of separate excel files, so if you can get 1 into SQL, you can get them all there.  If I were trying to combine 10 separate workbooks into 1, I would use "Get Last Row" to know where I left off in my compiling.

     

    As far as MS Teams, I am sure it is full of Windows UI elements that will all be readable by PAD.  If not, "Move Mouse to Image" is always a last resort.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks a lot @MichaelAnnis for your quick response.

     

    So regarding the excel part , the solution you mentioned will be like , if i have 5-6 excel files in a folder , so need to combine all those files data into 1 single excel file?  IF  this is the case again there are efforts of getting all files data into 1 file or whether this part can be automated? Kindly brief it more in here.

     

    So coming to "MS Teams action", so you meant here , recording the action of sending the files on teams channel? using desktop recorder? But as every time there will be different files based on the data. Performing recording on this can send the same files across right? Or if there any , kindly brief it .

     

    Thanks in advance.

     

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hello @MichaelAnnis ,

     

    Awaiting for your response , if there could be any solution for this & kindly brief if on the same.

  • MichaelAnnis Profile Picture
    5,727 Moderator on at

    Apologies for the delay, I had this flagged in my email, but I get busy around the 1st.

     

    Are you familiar with Excel VBA?  This would be your best option for combining Excel Files.

     

    I can't seem to add an attachment here, but I made a simple excel macro file where you can list the paths and filenames of all your workbooks and the Macro - "CombineExcelFiles" will combine the workbooks you listed in columns A & B and save it to the path and filename defined in E2 & F2, respectively.

     

    MichaelAnnis_0-1630598276892.png

     

    Assumptions of this macro are that each workbook has the same column set in the same order, so the title row of each workbook after the 1st workbook is ignored and only rows 2 through the last row are added to the first workbook and then that first workbook is saved with the new filepath and filename.

     

    The full macro is pasted below, so you can create your own.  This workbook is called "CombineExcelFiles.xlsm" which is relevant to the macro language, so be sure to label it that after you create it.

     

    If you have any questions, feel free to reach out, I will answer the Teams question separately.

     

    Best of Luck!

     

    Here is the full macro that you can copy and paste into a new Excel VBA Macro:

    Sub CombineExcelFiles()
    '
    ' CombineExcelFiles Macro
    '

    '
    'get loop max (last row of filenames)
    Dim LoopMax As Long
    Range("A1").Select
    Selection.End(xlDown).Select
    LoopMax = Selection.Row

    'Define the string variables filepath and filename
    Dim strfilepath As String
    Dim strfilename As String

    'i is the loop index, we start at 2 and work until loop max; LR is last row, used throughout the loop; NWB is New Workbook used through Loop
    Dim NWB As Workbook
    Dim LR As Long
    Dim i As Long
    i = 2

    Do
    'define the filepath and filename
    Workbooks("CombineExcelFiles.xlsm").Activate
    strfilepath = Range("A" & i)
    strfilename = Range("B" & i)
    'open the workbook
    ChDir (strfilepath)
    Workbooks.Open filename:=strfilepath & "\" & strfilename
    'If the LoopIndex (i) = 2, declare Master WorkBook (MWB)
    If i = 2 Then
    'indentify workbookname as this will become the master for all other workbooks to be copied to
    Dim MWB As Workbook
    Set MWB = ActiveWorkbook
    Else 'if i <> 2
    'copy the rows from the new workbook and paste them in the master workbook
    'define New WorkBook (NWB)
    Set NWB = ActiveWorkbook
    'get the last row (LR) of the new workbook
    Range("A1").Select
    Selection.End(xlDown).Select
    LR = Selection.Row
    'assuming a title row, copy all rows 2 through last row
    Rows("2:" & LR).Copy
    'go to master workbook
    Workbooks(MWB.Name).Activate
    'select first available cell in column A
    Range("A1").Select
    Selection.End(xlDown).Select
    Selection.Offset(1, 0).Select
    'paste all copied data in first available cell in column A
    ActiveSheet.Paste
    'remove alerts to stop copied rows from causing error and close the excel file - it is no longer needed
    Workbooks(NWB.Name).Activate
    Application.DisplayAlerts = False
    Workbooks(NWB.Name).Close
    Application.DisplayAlerts = True
    End If
    'increase loopindex (i) by 1
    i = i + 1
    Loop Until i > LoopMax 'Loop will stop when i hits a blank row in columns A & B
    'define the path and filename of the combined workbook
    Windows("CombineExcelFiles.xlsm").Activate
    Dim savefilepath As String
    Dim savefilename As String
    savefilepath = Range("E2")
    savefilename = Range("F2")
    'go back to Master Workbook and Save As with defined path and name
    Workbooks(MWB.Name).Activate
    ActiveWorkbook.SaveAs filename:=savefilepath & "\" & savefilename
    End Sub

     

     

  • Verified answer
    MichaelAnnis Profile Picture
    5,727 Moderator on at

    So coming to "MS Teams action", so you meant here , recording the action of sending the files on teams channel? using desktop recorder? But as every time there will be different files based on the data. Performing recording on this can send the same files across right? Or if there any , kindly brief it .

     

    Yes, so, what you will want to do is use the recorder.  Then, replace all points that reference the file that you used with a variable.  And use PAD to populate the variable with the file that should be used each time.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks a ton @MichaelAnnis  for the work around, noted with teams . Working with script you sent on for excel workbooks.

    Also can you please suggest, the connection string for 'SQL SERVER AUTHENTICATION' , as I  need to copy the data from excel actions to SQL . I have MSSQL installed. 

    Thank you.

  • MichaelAnnis Profile Picture
    5,727 Moderator on at

    My apologies... I don't know how to get Excel into SQL as I rarely work with sequel.  You had said:  As I have seen actions or in the desktop recordings which opens only 1 excel file , as we need to mention the specific single excel file path.

    So, I thought if we could get them all into 1 excel file, then you would know how to get it into SQL.  You may want to post that part of the question on another board.  Best of luck!

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thank you @MichaelAnnis  , sure will post it in another board.

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 330

#2
11manish Profile Picture

11manish 282 Super User 2026 Season 2

#3
Henil Profile Picture

Henil 123

Last 30 days Overall leaderboard