Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I tried the above function <code>Sub UnZipFile(...)</code> under Excel 2010 and it was <strong>not</strong> working: Run-time error '91' (Object variable or With block not set) in the line</p> <pre><code>Set objArchive = objApp.Namespace(strArchive).Items() </code></pre> <p>and the line </p> <pre><code>Set objDest = objApp.Namespace(strDest) </code></pre> <p>is silently also not working: After execution the <code>objDest</code> is still nothing!</p> <p>Microsoft's <code>.Namespace()</code> accepts as parameter either an object, a string constant or a string variable. With string variables there are often suspicious problems, which are requiring an workaround: </p> <pre><code>Set objArchive = objApp.Namespace(**CStr(** strArchive **)**).Items() Set objDest = objApp.Namespace(**CStr(** strDest **)**) </code></pre> <p>or an alternative workaround </p> <pre><code>Set objArchive = objApp.Namespace(**"" &amp;** strArchive).Items() Set objDest = objApp.Namespace(**"" &amp;** strDest) </code></pre> <p>And the line <code>objDest.CopyHere objArchive</code> was also not working: The destination folder remained empty!</p> <p>Here a version, which is working in Excel 2010 and most probably also in other environments:</p> <pre><code>Sub UnZipFile(strZipArchive As String, strDestFolder As String) Dim objApp As Object Dim vItem As Variant Dim objDest As Object Set objApp = CreateObject("Shell.Application") Set objDest = objApp.Namespace(CStr(strDestFolder)) For Each vItem In objApp.Namespace(CStr(strZipArchive)).Items objDest.CopyHere vItem Next vItem End Sub </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload