Chercher un mot dans la zone texte

Bonjour à tous,

Je voudrais récupérer la liste des fichiers excel "dans un dossier" qui contient un mot ".." dans la zone texte

Bonjour,

Dans ta question ... tu parles de la ' zone Texte ' ...

Peux-tu préciser ta pensée ...

Qu'est-ce-que la ' zone Texte ' ...???

Merci Jemes,

ZoneTexte cest le texte inséré dans une shape.

en fait moi je veux chercher un mot ds shapes

Re,

Je ne sais pas si tu as déjà ta macro pour balayer tous les fichiers de ton répertoire ...

Au cas où tu ne l'aies pas encore ... il en existe des dizaines sur le Forum ..il te suffit de faire une recherche FSO ...

En espèrant que cela t'aide ...

Bonjour,

Au sujet de FSO et de construire la liste des fichiers dans ton répertoire dont les noms contiennent le mot déterminé ...

ci joint un exemple à adapter à ta situation :

Sub ListedesFichiers()
'Ne pas oublier reférence à Microsoft Scripting Runtime
'Outils > Références in the Visual Basic Editor (Alt+F11)
Dim objFSO As FileSystemObject
Dim objFolder As Folder
Dim objFile As File
Dim strPath As String
Dim strFile As String
Dim LigSuiv As Long

    'Adapter le répertoire ''''''''''''''''
    strPath = "C:\Users\MesDocuments\"

    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFolder = objFSO.GetFolder(strPath)

    'Tester si répertoire contient des fichiers
    If objFolder.Files.Count = 0 Then
        MsgBox "Aucun Fichier dans ce répertoire ...", vbExclamation
        Exit Sub
    End If

    Application.ScreenUpdating = False

    Cells(1, "A").Value = "Nom_Fichier"
    Cells(1, "B").Value = "Taille"
    Cells(1, "C").Value = "Date"
    LigSuiv = Cells(Rows.Count, "A").End(xlUp).Row + 1

    'Boucle pour tester si les noms contiennent
    For Each objFile In objFolder.Files
        If InStr(1, objFile.Name, "Texte de la Zone Texte") > 0 Then
            Cells(LigSuiv, 1).Value = objFile.Name
            Cells(LigSuiv, 2).Value = objFile.Size
            Cells(LigSuiv, 3).Value = objFile.DateLastModified
            LigSuiv = LigSuiv + 1
         End If
    Next objFile

    'Ajuster la taille des Colonnes
    Columns.AutoFit

    Application.ScreenUpdating = True
End Sub

En espèrant que cela t'aide

Bonjour ,

j'ai essayé avec ce code ca marche pas.

Le code ci-dessous me revois seulement les mots à chercher en cellules et moi je veux aussi chercher dans la zone de Texte (shape).

Sub SearchFolders()

'UpdatebyKutoolsforExcel20151202

Dim xFso As Object

Dim xFld As Object

Dim xStrSearch As String

Dim xStrPath As String

Dim xStrFile As String

Dim xOut As Worksheet

Dim xWb As Workbook

Dim xWk As Worksheet

Dim xRow As Long

Dim xFound As Range

Dim xStrAddress As String

Dim xFileDialog As FileDialog

Dim xUpdate As Boolean

Dim xCount As Long

On Error GoTo ErrHandler

Set xFileDialog = Application.FileDialog(msoFileDialogFolderPicker)

xFileDialog.AllowMultiSelect = False

xFileDialog.Title = "Select a forlder"

If xFileDialog.Show = -1 Then

xStrPath = xFileDialog.SelectedItems(1)

End If

If xStrPath = "" Then Exit Sub

xStrSearch = "KTE"

xUpdate = Application.ScreenUpdating

Application.ScreenUpdating = False

Set xOut = Worksheets.Add

xRow = 1

With xOut

.Cells(xRow, 1) = "Workbook"

.Cells(xRow, 2) = "Worksheet"

.Cells(xRow, 3) = "Cell"

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

Set xFso = CreateObject("Scripting.FileSystemObject")

Set xFld = xFso.GetFolder(xStrPath)

xStrFile = Dir(xStrPath & "\*.xls*")

Do While xStrFile <> ""

Set xWb = Workbooks.Open(Filename:=xStrPath & "\" & xStrFile, UpdateLinks:=0, ReadOnly:=True, AddToMRU:=False)

For Each xWk In xWb.Worksheets

Set xFound = xWk.UsedRange.Find(xStrSearch)

If Not xFound Is Nothing Then

xStrAddress = xFound.Address

End If

Do

If xFound Is Nothing Then

Exit Do

Else

xCount = xCount + 1

xRow = xRow + 1

.Cells(xRow, 1) = xWb.Name

.Cells(xRow, 2) = xWk.Name

.Cells(xRow, 3) = xFound.Address

.Cells(xRow, 4) = xFound.Value

End If

Set xFound = xWk.Cells.FindNext(After:=xFound)

Loop While xStrAddress <> xFound.Address

Next

xWb.Close (False)

xStrFile = Dir

Loop

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

End With

MsgBox xCount & "cells have been found", , "Kutools for Excel"

ExitHandler:

Set xOut = Nothing

Set xWk = Nothing

Set xWb = Nothing

Set xFld = Nothing

Set xFso = Nothing

Application.ScreenUpdating = xUpdate

Exit Sub

ErrHandler:

MsgBox Err.Description, vbExclamation

Resume ExitHandler

End Sub

Bonjour,

Tu m'expliques que tu as utilisé le code de KutoolsforExcel ... qui ne fait pas ce que tu veux ...

As-tu essayé d'adapter le code que je t'ai proposé ...???

J'ai essayé ca marche

J'ai pas encore réussi

J'ai essayé ca marche

J'ai pas encore réussi

Re,

il faut que je comprenne bien la différence entre ta première phrase ... ET ... ta seconde phrase ...

HHh

Erreur de frappe

j'ai essaye Ca marche pas .

Merci bcq pour votre support

Re,

Malheureusement, le commentaire est beaucoup trop vague pour savoir ce qui ne fonctionne pas ...

Dans l'ordre :

1. As-tu coché la référence à Microsoft Scripting Runtime dans Outils > Références ...???

nn

nn

Si ta réponse signifie non ....

C'est normal que rien ne fonctionne ... car il faut avoir cette librairie en référence ...

Rechercher des sujets similaires à "chercher mot zone texte"