10. november 2003 - 12:13Der er
13 kommentarer og 1 løsning
Søgning i valgfri folder
Jeg har fundet følgende stump kode i Hjælpen: Set fs = Application.FileSearch With fs .LookIn = "C:\My Documents" .FileName = "cmd*.*" If .Execute > 0 Then MsgBox "There were " & .FoundFiles.Count & _ " file(s) found." For i = 1 To .FoundFiles.Count MsgBox .FoundFiles(i) Next i Else MsgBox "There were no files found." End If End With
og det er hvad jeg har brug for, men vil gerne åbne en dialogboks så brugeren kan vælge hvilken folder der skal undersøges.
Dim sName As String With Dialogs(wdDialogFileOpen) If .Display <> 0 Then sName = CurDir & "\" & .Name End If End With
Position = InStrRev(sName, "\")
Søg = Mid(sName, 1, Position)
Set fs = Application.FileSearch With fs .LookIn = Søg .FileName = "cmd*.*" If .Execute > 0 Then MsgBox "There were " & .FoundFiles.Count & _ " file(s) found." For i = 1 To .FoundFiles.Count MsgBox .FoundFiles(i) Next i Else MsgBox "There were no files found." End If End With
Dim sName As String With Dialogs(wdDialogFileOpen) If .Display <> 0 Then sName = CurDir & "\" End If End With
Set fs = Application.FileSearch With fs .LookIn = Søg .FileName = "cmd*.*" If .Execute > 0 Then MsgBox "There were " & .FoundFiles.Count & _ " file(s) found." For i = 1 To .FoundFiles.Count MsgBox .FoundFiles(i) Next i Else MsgBox "There were no files found." End If End With
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.