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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Unzipping a file and saving to a folder in Excel VBA

Status
Not open for further replies.

Aurillius

Programmer
Jun 3, 2004
60
CA
Hi,
I've been searching through various forums on the web and then attempted to search for a solution on Tek-tips, no luck. I've also seen that many are getting the same error that I was getting.
Using VBA within Excel, I want to open a zip archive and save to a selected folder. Here is my code:

'Dims and code to determine file and location

Call UnzipAFile(MyPath & LatestFile, MyPath)

Sub UnzipAFile(zippedFileFullName As Variant, unzipToPath As Variant)

Dim ShellApp As Object

Set ShellApp = CreateObject("Shell.Application")
ShellApp.Namespace(unzipToPath).CopyHere ShellApp.Namespace(zippedFileFullName).items 'this is where the error happens

End Sub

I keep getting the same runtime 91 error, "Object variable or With block variable set" and I've even added Microsoft Shell Controls and Automation to my references and same error.

Please help!!

Mark

 
I answered my own question. The issue is (and is for probably many people), I included a backslash "\" at the end of my path "unzipToPath", this was for some other code. I spent way too much time debugging this and it was an easy fix.

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top