title: Get error 'run-time error -2147024894(80070002)'... when extract zip file
body: <p>I have one archive file that contains multiple subfolders in it.</p>
  
  <p>For example : <code>C:\Documents and Settings\Owner\Desktop\Macro\Intermediación Financiera\2013\12\BCO_Ind.zip</code></p>
  
  <p>In the <strong>BCO_Ind.zip</strong> contains this subfolder <code>scbm\2013\09\fileThatIWant.xls</code></p>
  
  <p>These subfolder are different for each archive file although it has the same name.
  the things is i want the last file from the last subfolder. </p>
  
  <p>I modified the code from <a href="http://excelexperts.com/unzip-files-using-vba" rel="nofollow">http://excelexperts.com/unzip-files-using-vba</a> and from www.rondebruin.nl/win/s7/win002.htm</p>
  
  <p>The problem is I get an error which is:
  <code>run-time error -2147024894(80070002)': Method 'Namespace' of Object 'IShellDispatch4' failed</code>.</p>
  
  <p>I try to search all from the website but I didn't find the solution for almost a week.
  Here is the code:</p>
  
  <pre><code>Sub TestRun()
  'Change this as per your requirement
  Call unzip("C:\Documents and Settings\Owner\Desktop\Macro\Intermediación Financiera\2013\12\", "C:\Documents and Settings\Owner\Desktop\Macro\Intermediación Financiera\2013\12\BCO_Ind.zip")
  End Sub
  
  Public Function unzip(targetpath As String, filename As Variant, Optional SCinZip As String, _
                      Optional excelfile As String) As String '(targetpath As String, filename As Variant)
  
  Dim strScBOOKzip As String, strScBOOK As String:  strScBOOK = targetpath 
  Dim targetpathzip As String, excelpath As String 
  Dim bzip As Boolean: bzip = False
  Dim oApp As Object
  Dim FileNameFolder As Variant
  Dim fileNameInZip As Object
  Dim objFSO As Scripting.FileSystemObject
  Dim filenames As Variant: filenames = filename
  
  If Right(targetpath, 1) &lt;&gt; Application.PathSeparator Then
     targetpathzip = targetpath &amp; Application.PathSeparator
  Else
     targetpathzip = targetpath
  End If
  
  FileNameFolder = targetpathzip
  Set objFSO = CreateObject("Scripting.FileSystemObject")
  Set oApp = CreateObject("Shell.Application")
  ''-----i get an error in here
  For Each fileNameInZip In oApp.Namespace(filenames).Items
    If objFSO.FolderExists(FileNameFolder &amp; fileNameInZip) Then
      objFSO.DeleteFolder FileNameFolder &amp; fileNameInZip, True: Sleep 1000
    End If
  ''-----i get an error in here too
    oApp.Namespace(FileNameFolder).CopyHere oApp.Namespace(filename).Items.item(CStr(fileNameInZip))
    bzip = True
  Next fileNameInZip
  
  If bzip Then
    excelpath = findexactfile(targetpath) ' this will go to the function that find the file from subfolders
  Else
    excelpath = ""
  End If
  searchfolder = FileNameFolder &amp; fileNameInZip
  
  finish:
    unzip = excelpath
    Set objFSO = Nothing
    Set oApp = Nothing
  End Function
  </code></pre>
  
  <p>I also tick some tools>references in development macro but it still get the same error. I really stress+frustrated right now. Please help me to fix it. Also, is there have a simple code as my references to find the file from subfolder after the file is extract? I really appreciate it if someone can share the code.</p>