PDA

View Full Version : [SOLVED:] Unzip in Excel/VBA for Mac - CreatObject("Shell.Application") not working



Colin_In_BE
01-13-2023, 12:16 AM
Hello,
I'm trying to get some VBA to work on my Mac (Big Sur 11.7.2) to Unzip a Zip file.

This is the code that would normally work on a Windows system ... but, I have a Mac :

Sub UnzipFile(zippedFileFullName As Variant, unzipToPath As Variant)
Dim ShApp As Object
Set ShApp = CreateObject("Shell.Application")
ShApp.Namespace(unzipToPath).CopyHere ShApp.Namespace(zippedFileFullName).items
End Sub
This is how I would call it:

Call UnzipFile("/Users/Colin/Documents/Test/eurofxref-hist.zip", "/Users/Colin/Documents/Test")
When I call it (or step through the Sub), as ActiveX isn't available on the Mac, I get: Run-Time error '429': ActiveX component can't create object.

Does anyone have an idea how to get an equivalent solution working on a Mac?

Many thanks.

UPDATE : Just found one way to do it, with a Mac App that I wrote to call the Archive Utility.app and run with:

Shell "/Users/Colin/Documents/Computing/Scripts/Expand_Zip.app"
Maybe there is a more elegant way to do this within VBA.

Aussiebear
01-13-2023, 12:47 AM
Didn't you get help in Excel Forum?

Colin_In_BE
01-13-2023, 12:52 AM
No, not yet ; it was just suggested to find a specific Apple forum (and I didn't find much on the Apple forums on VBA).

Aussiebear
01-13-2023, 12:59 AM
Have you cross posted this thread else where? Simple courtesy about cross posting should have been the order of the day here. It'll be up to the members here whether they assist you or not given that you have cross posted.

Colin_In_BE
01-13-2023, 01:51 AM
In the FAQs related to multiposting (cross-posting), clinking the link in "If you are still confused, read A message to forum cross posters." gives me a 404 error.
I would have liked to delete the posts on the other site, as it appears they don't have the knowledge of the Mac side. But, it seems not to be possible.
If you have a solution to improve this situation now, I'd be pleased to read it. And I know the approach for the future. Thanks.

Aussiebear
01-13-2023, 04:11 AM
Mate... it's about the the integrity of the person asking the question. If for example you had said... "I've asked this question here but it's failed to extract any real response"... no issues, or you had said I've posted this here and to date there's been minimal response.... again no issues. We will if possible try to assist you. On the other hand if you cross post and don't want to acknowledge it... members here ( who may well be members elsewhere) take this as a sign that you don't recognise their contributions and may well not try to assist. If you wish to post here in this forum, please feel free tp do so, but do so with complete honesty.

Colin_In_BE
01-21-2023, 01:25 AM
Resolved by writing an AppleScript, which I call as an app from VBA.