ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Search for file with *. extensions (https://www.excelbanter.com/excel-programming/372151-search-file-%2A-extensions.html)

JustinP

Search for file with *. extensions
 
I need to search for files with the extensions "*.mxd" and "*.wor". How
can I do this using the code below with duplicating it all?

Sub FindFiles()
Dim i As Long
With Application.FileSearch
.SearchSubFolders = True
.LookIn = "C:\"
.Filename = "*.mxd"
.FileType = msoFileTypeAllFiles
.Execute
For i = 1 To .FoundFiles.Count
Range("A" & i) = .FoundFiles(i)
Next
End With
End Sub


JustinP

Search for file with *. extensions
 
I mean *without* duplicating it...


JustinP wrote:
I need to search for files with the extensions "*.mxd" and "*.wor". How
can I do this using the code below with duplicating it all?

Sub FindFiles()
Dim i As Long
With Application.FileSearch
.SearchSubFolders = True
.LookIn = "C:\"
.Filename = "*.mxd"
.FileType = msoFileTypeAllFiles
.Execute
For i = 1 To .FoundFiles.Count
Range("A" & i) = .FoundFiles(i)
Next
End With
End Sub



Leo Heuser

Search for file with *. extensions
 
"JustinP" skrev i en meddelelse
ups.com...
I mean *without* duplicating it...


JustinP wrote:
I need to search for files with the extensions "*.mxd" and "*.wor". How
can I do this using the code below with duplicating it all?

Sub FindFiles()
Dim i As Long
With Application.FileSearch
.SearchSubFolders = True
.LookIn = "C:\"
.Filename = "*.mxd"
.FileType = msoFileTypeAllFiles
.Execute
For i = 1 To .FoundFiles.Count
Range("A" & i) = .FoundFiles(i)
Next
End With
End Sub



Hi Justin

Using semicolon
..Filename = "*.mxd;*.wor"
will do the job.


--
Best regards
Leo Heuser

Followup to newsgroup only please.





All times are GMT +1. The time now is 08:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com