Tema: VBA search through file content
Autorius: CurrentUser
Data: 2019-12-17 21:04:06
Hi,

Reikia pertikrinti >1K failu (visi xls) ir jei jo celeje (C3) yra tekstas 
"aaaa", ta faila reikia pazymeti, tarkim Tag="AA"
Turim toki koda:
Sub LoopAllFilesInFolder()

Dim folderName As String
Dim FSOLibrary As Object
Dim FSOFolder As Object

'Set the file name to a variable
folderName = "D:\AAA\"

'Set all the references to the FSO Library
Set FSOLibrary = CreateObject("Scripting.FileSystemObject")
Set FSOFolder = FSOLibrary.GetFolder(folderName)
Set FSOFile = FSOFolder.Files

'Use For Each loop to loop through each file in the folder
For Each FSOFile In FSOFile

'Va cia nzn kaip nurodyti, kad failas - xl'inis ir jam taikomi Excelio 
atributai:
    If FSOFile.Worksheets("Sheet1").Range("C3") = "aaaa" Then
' tuomet failo taguose pažymime "AA"
        FSOFile.Attributes.Tag = "AA"
    End If
    'Debug.Print FSOFile.Name
Next

'Release the memory
Set FSOLibrary = Nothing
Set FSOFolder = Nothing
Set FSOFile = Nothing

End Sub

Ar padetu kas nors "damushti"ta koda?
Muchas Gracias!!!