Reputation: 198
I am trying to iterate all zipped folder inside a folder and extract it into another folder location.
Set objFSO = CreateObject("Scripting.FileSystemObject")
ExtractTo = "C:\Users\070637\Desktop\Mbp\unzipped"
Set SourceFolder = objFSO.GetFolder("C:\Users\070637\Desktop\Mbp")
For each file in SourceFolder.Files
if Right(LCase(file.Name),4)=".zip" then
Set objShell = CreateObject("Shell.Application")
set FilesInZip = objShell.NameSpace(file).items
objShell.NameSpace(ExtractTo).CopyHere(FilesInZip)
End if
Next
While executing the script I'm getting an "object required" error in the line
set FilesInZip = objShell.NameSpace(file).items
Upvotes: 0
Views: 814
Reputation: 11
Kindly add to watch and check out both file and file.path. File is object variant that will contain many properties of that file whereas file.path will contain only the string value that is the actual path. So when directly retrieving file.Items, its not sure about for which property you are trying to retrieve its items and hence the error. When specifying file.path, its able to retrieve the item from the specified path
Upvotes: 0
Reputation: 11
change to file.path instead of file in set FilesInZip = objShell.NameSpace(file).items
Upvotes: 1