cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mwyller
Level: Power Up

Search 'New Files' in SharePoint folder for specific text

We're automated some processes using a robotics package that when complate, drops an Excel audit file into a SharePoint folder. I have alerts configured to notify when new audit files are saved to this 'Audit_Report' folder.

What I would like to add is an alert when the new 'Audit_Report.xlsx' contains specific text somewhere in the file, such as:

  • Errors Found
  • Exception Encountered
  • Exception occurred

Can this be done using Flow, or do I need custom dev to make it work?

Thanks, Mike Wyller

 

-------

I found some vba code that will search an Excel file for 1 text condition, but I want the search process to kick off when the new audit report file is saved. As it is, I need to run the macro manually and once for each text condition.

-------

Option Explicit

Sub SearchFolders()

   Dim fso As Object

   Dim fld As Object

   Dim strSearch As String

   Dim strPath As String

   Dim strFile As String

   Dim wOut As Worksheet

   Dim wbk As Workbook

   Dim wks As Worksheet

   Dim lRow As Long

   Dim rFound As Range

   Dim strFirstAddress As String

   On Error GoTo ErrHandler

   Application.ScreenUpdating = False

   'Change as desired

   strPath = "R:\Document Library\AssistEdge_RPA\Audit Report_UAT"                 '<--- Change directory here

   strSearch = "Exception Occurred"               '<--- Change term to search for here

   Set wOut = Worksheets.Add

   lRow = 1

   With wOut

       .Cells(lRow, 1) = "Workbook"

       .Cells(lRow, 2) = "Worksheet"

       .Cells(lRow, 3) = "Cell"

       .Cells(lRow, 4) = "Text in Cell"

       Set fso = CreateObject("Scripting.FileSystemObject")

       Set fld = fso.GetFolder(strPath)

       strFile = Dir(strPath & "\*.xlsx") '<-- Currently searching all Excel files. Change extension here

       Do While strFile <> ""

           Set wbk = Workbooks.Open _

             (Filename:=strPath & "\" & strFile, _

             UpdateLinks:=0, _

             ReadOnly:=True, _

             AddToMRU:=False)

           For Each wks In wbk.Worksheets

               Set rFound = wks.UsedRange.Find(strSearch)

               If Not rFound Is Nothing Then

                   strFirstAddress = rFound.Address

               End If

               Do

                   If rFound Is Nothing Then

                       Exit Do

                   Else

                       lRow = lRow + 1

                       .Cells(lRow, 1) = wbk.Name

                       .Cells(lRow, 2) = wks.Name

                       .Cells(lRow, 3) = rFound.Address

                       .Cells(lRow, 4) = rFound.Value

                   End If

                   Set rFound = wks.Cells.FindNext(After:=rFound)

               Loop While strFirstAddress <> rFound.Address

           Next

           wbk.Close (False)

           strFile = Dir

       Loop

       .Columns("A:D").EntireColumn.AutoFit

   End With

   MsgBox "Search Complete"

ExitHandler:

   Set wOut = Nothing

   Set wks = Nothing

   Set wbk = Nothing

   Set fld = Nothing

   Set fso = Nothing

   Application.ScreenUpdating = True

   Exit Sub

ErrHandler:

   MsgBox Err.Description, vbExclamation

   Resume ExitHandler

End Sub

 

1 REPLY 1
Community Support Team
Community Support Team

Re: Search 'New Files' in SharePoint folder for specific text

Hi @ mwyller,

 

Could you please share a screenshot of the configuration of your flow?

Do you want to search for specific test from the file when an Excel file is created in the sharepoint library?

 

I have made a test on my side,

Searching for specific test from the file when an file is created in the sharepoint library is not supported in microsoft flow currently, I afraid that there is no way to achieve your needs in Microsoft Flow currently.

 

If you would like this feature to be added in Microsoft Flow, please submit an idea to Flow Ideas Forum:

https://powerusers.microsoft.com/t5/Flow-Ideas/idb-p/FlowIdeas

 

 

Regards,
Alice Zhang

Helpful resources

Announcements
firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (5,078)