Cinema
10-21-2016, 01:45 AM
Hi,
I tried to unzip zip files by Looping through the subfolders. I am getting the error 91 in Line "oApp.Namespace(FileNameFolder).CopyHere oApp.Namespace(My_FILE).items"
Can someone help???
Sub TestRun()
Dim My_DESTINATION As String
Dim My_LOCATION As String
My_DESTINATION = Range("B1").Value
For My_ROWS = 5 To Range("A" & Rows.Count).End(xlUp).Row
My_LOCATION = My_DESTINATION & Range("A" & My_ROWS).Value
My_FILE = My_FILE = My_DESTINATION & Range("A" & My_ROWS).Value & "\" & Range("B" & My_ROWS).Value
Call UnZip(My_FILE, My_DESTINATION)
Next My_ROWS
End Sub
Sub UnZip(ByVal My_FILE As String, My_DESTINATION As String)
Dim oApp As Object
Dim FileNameFolder As Variant
If Right(My_DESTINATION, 1) <> Application.PathSeparator Then
My_DESTINATION = My_DESTINATION & Application.PathSeparator
End If
FileNameFolder = My_DESTINATION
Set oApp = CreateObject("Shell.Application")
oApp.Namespace(FileNameFolder).CopyHere oApp.Namespace(My_FILE).items
End Sub
I tried to unzip zip files by Looping through the subfolders. I am getting the error 91 in Line "oApp.Namespace(FileNameFolder).CopyHere oApp.Namespace(My_FILE).items"
Can someone help???
Sub TestRun()
Dim My_DESTINATION As String
Dim My_LOCATION As String
My_DESTINATION = Range("B1").Value
For My_ROWS = 5 To Range("A" & Rows.Count).End(xlUp).Row
My_LOCATION = My_DESTINATION & Range("A" & My_ROWS).Value
My_FILE = My_FILE = My_DESTINATION & Range("A" & My_ROWS).Value & "\" & Range("B" & My_ROWS).Value
Call UnZip(My_FILE, My_DESTINATION)
Next My_ROWS
End Sub
Sub UnZip(ByVal My_FILE As String, My_DESTINATION As String)
Dim oApp As Object
Dim FileNameFolder As Variant
If Right(My_DESTINATION, 1) <> Application.PathSeparator Then
My_DESTINATION = My_DESTINATION & Application.PathSeparator
End If
FileNameFolder = My_DESTINATION
Set oApp = CreateObject("Shell.Application")
oApp.Namespace(FileNameFolder).CopyHere oApp.Namespace(My_FILE).items
End Sub