Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unzip Files In Folder Using VBA

Status
Not open for further replies.

AccessHelp123

Programmer
Apr 27, 2005
91
US
Hi, I am trying to unzip all zip files in a folder using VBA. For some reason Application.filesearch does not find zip files.. I am using the code below...

With Application.FileSearch
.NewSearch
.fileType = msofiletypeAllFiles
.filename = "*.zip"
.LookIn = filePath
.matchtextExactly = True

If .Execute() > 0 Then

For EveryFile = 1 To .foundfiles.Count

fPathTemp = .foundfiles(EveryFile)

UnZip_ZipFile_1 filename, filePath

Next
Else
MsgBox "There were no files found."
End If
'Application.ScreenUpdating = True
End With

It does not find zip files..

I also tried using the Dir function but after the first call it does not find any more zip files...

filename = Dir(filePath & "*.zip")
While filename <> ""

UnZip_ZipFile_1 filePath & filename, filePath

filename = Dir()
' The filename is empty after this call for some reason
'even though i have more than 5 files in the folder

Wend

Exit Sub

Can someone please help?



 
Does by chance UnZip_ZipFile_1 call the Dir function too ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Yes .. I noticed it does... I guess that is what the problem is.. Is there anyway I can do that using application.filesearch? thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top