Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excel 2016 For Mac 64-Bit Update #248

Closed
jfrench9 opened this issue Aug 23, 2016 · 19 comments
Closed

Excel 2016 For Mac 64-Bit Update #248

jfrench9 opened this issue Aug 23, 2016 · 19 comments

Comments

@jfrench9
Copy link

Excel 2016 for Mac was upgraded to 64-bit from 32-bit versions. This has caused issues with the VBA-Web functionality in Excel 2016 for Mac. Microsoft acknowledges that this is an issue for many add-ins.

It appears that some of the core functionality that makes this work in Excel 2016 for Mac may not be configured for the new 64-bit versions that were just rolled out yesterday. Any idea on how to resolve this issue?

@timhall
Copy link
Member

timhall commented Aug 25, 2016

Hi @jfrench9 I don't currently have access to a Mac for testing, so I'm not sure what exactly the issues are or how to resolve them. Do you have more specifics (error messages, compilation issues, etc) on the issues that you are receiving?

@jfrench9
Copy link
Author

jfrench9 commented Aug 26, 2016

When I run the add-on I created with VBA-Web integrated, I am getting this error:
screen shot 2016-08-26 at 12 35 13 am

I believe this error is referring to the declare statements in the Mac code:
https://github.com/VBA-tools/VBA-Web/blob/master/src/WebHelpers.bas#L147-L150
https://github.com/VBA-tools/VBA-Web/blob/master/src/WebHelpers.bas#L240-L243

If I add PtrSafe to the Declare statements similar to the Windows code, Excel crashes every time.

This worked just fine before the update referenced above was pushed out on Aug 22nd. There is quite a bit of chatter about Excel 2016 for Mac being upgraded from 32 bit to 64 bit, so I would imagine the libraries referenced in these declare statements are not playing nicely with the new architecture.

@rikochet
Copy link

@jfrench9 I am currently experiencing the same issue as you. Although I don't believe it's as simple as adding PtrSafe to the Declare statements.. It would appear that Long types may need to be changed to LongPtr..

i.e.
Private Declare PtrSafe Function utc_popen Lib "libc.dylib" Alias "popen" (ByVal utc_Command As String, ByVal utc_Mode As String) As Long

becomes

Private Declare PtrSafe Function utc_popen Lib "libc.dylib" Alias "popen" (ByVal utc_Command As String, ByVal utc_Mode As String) As LongPtr

I'm not familiar with VB though perhaps this link will help?

https://msdn.microsoft.com/library/gg264421.aspx?f=255&MSPPError=-2147217396

@rikochet
Copy link

@jfrench9, @timhall
Ok, so this solved the issue for me..

#If Mac Then
Private Declare PtrSafe Function web_popen Lib "libc.dylib" Alias "popen" (ByVal command As String, ByVal mode As String) As LongPtr
Private Declare PtrSafe Function web_pclose Lib "libc.dylib" Alias "pclose" (ByVal file As LongPtr) As Long
Private Declare PtrSafe Function web_fread Lib "libc.dylib" Alias "fread" (ByVal outStr As String, ByVal size As LongPtr, ByVal items As LongPtr, ByVal stream As LongPtr) As Long
Private Declare PtrSafe Function web_feof Lib "libc.dylib" Alias "feof" (ByVal file As LongPtr) As LongPtr
#End If
Public Function ExecuteInShell(web_Command As String) As ShellResult
#If Mac Then
    Dim web_File As LongPtr
    Dim web_Chunk As String
    Dim web_Read As Long

    On Error GoTo web_Cleanup

    web_File = web_popen(web_Command, "r")

    If web_File = 0 Then
        ' TODO Investigate why this could happen and what should be done if it happens
        Exit Function
    End If

    Do While web_feof(web_File) = 0
        web_Chunk = VBA.Space$(50)
        web_Read = web_fread(web_Chunk, 1, Len(web_Chunk) - 1, web_File)
        If web_Read > 0 Then
            web_Chunk = VBA.Left$(web_Chunk, web_Read)
            ExecuteInShell.Output = ExecuteInShell.Output & web_Chunk
        End If
    Loop

web_Cleanup:

    ExecuteInShell.exitCode = web_pclose(web_File)
#End If
End Function

I'm assuming if you want this to work on multiple Excel versions then might need to add a few more If VBA7 Then statements to either set the variable types to either Long or LongPtr..

@timhall
Copy link
Member

timhall commented Sep 4, 2016

@jfrench9 @rikochet thanks for the additional info! I'll make these changes shortly.

@av44
Copy link

av44 commented Oct 9, 2016

@timhall do you plan to release these changes? I am experiencing the same issue and, if possible, would prefer to get an "official" update instead of patching myself.
Thanks!

@ghost
Copy link

ghost commented Jan 13, 2017

Any update about this one ? I have the same issue and I don't even know where to patch it myself.

@general-albatross
Copy link

@timhall are you planning to pull this into main branch any time soon?

@timhall
Copy link
Member

timhall commented Feb 13, 2017

@blackphoenixinf I hadn't had an opportunity to test this on Mac as my Mac died a while back, but I was able to test this yesterday and will merge it in today.

@timhall timhall mentioned this issue Feb 13, 2017
3 tasks
@general-albatross
Copy link

@timhall if you need any help or feedback with testing this on Mac, I can give you a hand.

@markcollins
Copy link

I have a related issue after updating the most recent version of Office 365: Version 16.11.1 (180319) released 3/18/18. VBA is also version 7.1. When I run compile I get "Type Mismatch" error for "utc_Read". If I change it from LongPtr to Long, then "utc_popen" throws the error. This continues until I convert all LongPtr to Long.

@timhall
Copy link
Member

timhall commented Mar 21, 2018

Hi @markcollins I just got that error too, I've just gotten my Mac up-and-running and will fix this and a few other Mac issues shortly.

@timhall timhall reopened this Mar 21, 2018
@tmercieca
Copy link

Hi guys, any update on this Mac issue? I also get the same problem as @markcollins using Excel 2016 for Mac Version 16.11.1 (180319).

If I had to use an older version of Excel for Mac to work with VBA-Web without the issue in question, what would be recommended?

@timhall
Copy link
Member

timhall commented Apr 26, 2018

Fixed in v4.1.4

@timhall timhall closed this as completed Apr 26, 2018
@happyshows
Copy link

@timhall
Still not working on mac, cannot install correctly

ERROR 5: Invalid procedure call or argument

@zgrose
Copy link

zgrose commented May 20, 2018

I bet if you hit debug and give him the line number throwing the error it would be super helpful.

@LawrieMcintosh
Copy link

Hi Tim, Great library!

I'm having this same problem. I've tracked it down to do with the line:
web_File = web_popen(web_Command, "r")
In rikochets 26 Aug 2016 post

Depending on which error reporting I have turned on its generating
"An error occurred while preparing cURL request 53: File not found"
It appears to be referring to the libc.dylib file.
I also got a "vba run time error -2147210493 (80042b03)" which the internet wasn't much help with.

word version 16.16.10
I recently update my mac os to macOS mojave 10.14.4

Other plugins appear to have the same issue after recent updates (not sure if it was the mac of the microsoft updates that may have broken this, but seems to be fixable by replacing references of
"libc.dylib"
with:
"/usr/lib/libc.dylib"

Eg in context

Private Declare PtrSafe Function web_popen Lib "/usr/lib/libc.dylib" Alias "popen" (ByVal web_Command As String, ByVal web_Mode As String) As LongPtr Private Declare PtrSafe Function web_pclose Lib "/usr/lib/libc.dylib" Alias "pclose" (ByVal web_File As LongPtr) As LongPtr Private Declare PtrSafe Function web_fread Lib "/usr/lib/libc.dylib" Alias "fread" (ByVal web_OutStr As String, ByVal web_Size As LongPtr, ByVal web_Items As LongPtr, ByVal web_Stream As LongPtr) As LongPtr Private Declare PtrSafe Function web_feof Lib "/usr/lib/libc.dylib" Alias "feof" (ByVal web_File As LongPtr) As LongPtr

@LawrieMcintosh
Copy link

Haha, never mind, i was about to make a PR to suggest these changes but you've already implemented them in 4.1.6! You are two steps ahead of me!

@LawrieMcintosh
Copy link

OK I think i've tracked down another bug perhaps related to this issue
mac OSx Big Sur v11.4
Excel 16.63.1
Microsoft visual basic for applications 7.1

Error is with line 73 of webhelpers:
AutoProxy_fAutoDetect As Long

And as far as i can tell, the issue is with the "Long", perhaps with all such Longs...

(I started re-creating this module chunks of code at a time as the failure mode is a little elusive) I had to save the file, close and re-open excel and try to continue editing the code before the error would show up.

Alert: "An unexpected error has occurred. Auto-recovery has been disabled for this session of Excel."

Attempting to remove the module at this point results in a Microsoft visual basic internal error, and macros will not run again in this file (need to revert to an earlier backed up version)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants