#include #include #include #include #include Func Form1Close() Exit 0 EndFunc ;==>Form1Close Global $oShape Local $folder = "C:\Users\dolhascd\Desktop\MPTEST\IFCS Replace\actual\SR1\" RecursiveFileSearch($folder) Func RecursiveFileSearch($startDir, $depth = 0) If $depth = 0 Then Global $RFSstring = "" $search = FileFindFirstFile($startDir & "\*.*") If @error Then Return Local $oExcel = _Excel_Open(True) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "_Excel_Open Error", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) While 1 $next = FileFindNextFile($search) If @error Then ExitLoop If StringInStr(FileGetAttrib($startDir & "\" & $next), "D") Then RecursiveFileSearch($startDir & "\" & $next, $depth + 1) ElseIf StringInStr($startDir & "\" & $next, ".xls") Or StringInStr($startDir & "\" & $next, ".xlsx") Or StringInStr($startDir & "\" & $next, ".csv") Then Local $sWorkbook = $startDir & "\" & $next Local $oWorkbook = _Excel_BookOpen($oExcel, $sWorkbook) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "_Excel_BookOpen Error", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) Local $aResult1 = _Excel_RangeFind($oWorkbook, "Fixed Text1") If @error Then MsgBox($MB_SYSTEMMODAL, "_Excel_RangeFind Error 1", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) Local $aResult2 = _Excel_RangeFind($oWorkbook, "Fixed Text2") If @error Then MsgBox($MB_SYSTEMMODAL, "_Excel_RangeFind Error 2", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) Local $aResult3 = _Excel_RangeFind($oWorkbook, "Fixed Text3") If @error Then MsgBox($MB_SYSTEMMODAL, "_Excel_RangeFind Error 3", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) $var1 = $aResult1[0][2] ; Get the Cell where the fixed text is located Local $sResult = _Excel_RangeRead($oWorkbook, Default, StringReplace($var1, StringRight($var1, 2), StringRight($var1, 2)+1)) ; Get the cell's bellow value where the random string is located If @error Then MsgBox(0, "Range Read Error 1", "returned @error = " & @error) FileWriteLine(@ScriptDir & "\log.txt", "1: "& $sResult) $var2 = $aResult2[0][2] ; Get the Cell where the fixed text is located Local $sResult = _Excel_RangeRead($oWorkbook, Default, StringReplace($var2, StringRight($var2, 2), StringRight($var2, 2)+1)) ; Get the cell's bellow value where the random string is located If @error Then MsgBox(0, "Range Read Error 2", "returned @error = " & @error) FileWriteLine(@ScriptDir & "\log.txt", "2: "& $sResult) $var3 = $aResult3[0][2] ; Get the Cell where the fixed text is located Local $sResult = _Excel_RangeRead($oWorkbook, Default, StringReplace($var3, StringRight($var3, 2), StringRight($var3, 2)+1)) ; Get the cell's bellow value where the random string is located If @error Then MsgBox(0, "Range Read Error 3", "returned @error = " & @error) FileWriteLine(@ScriptDir & "\log.txt", "3: "& $sResult) ; Write the random text found FileWriteLine(@DesktopDir & "\Files Processed.txt", $startDir & "\" & $next) ; Write all file processed _Excel_BookClose($oWorkbook, False) EndIf WEnd _Excel_Close($oExcel, False, True) FileClose($search) If $depth = 0 Then Return StringSplit(StringTrimRight($RFSstring, 1), "*") EndFunc ;==>RecursiveFileSearch