在 MacOS 中下载图像的 Excel VBA 代码运行没有错误,但不下载任何图像

问题描述

我需要在 macOS 中使用 excel vba 下载图像,我猜有错误的部分是此功能不下载图像。我从来没有为 MacOS 编写过 vba 代码,所以有人能告诉我我是否必须选择任何库才能使此代码工作,或者我使用了错误的库。

 Option Explicit

Private Declare PtrSafe Function popen64 Lib "/usr/lib/libc.dylib" Alias "popen" (ByVal pCaller As LongPtr,ByVal szURL As String,ByVal szFileName As String,ByVal dwReserved As LongPtr,ByVal lpfnCB As LongPtr) As Long

Public Function DownloadURLtoFile(sSourceURL As String,_
sLocalFileName As String) As Boolean
 
Debug.Print sSourceURL
Debug.Print sLocalFileName
DownloadURLtoFile = popen64(0&,_
    sSourceURL,sLocalFileName,&H10,0&) = 0&

End Function

提前致谢....

我正在使用这种方式调用此函数并检查文件路径是否正确。

FolderString = FolderString & FirstName & "_" & LastName & ".jpg"
Debug.Print FolderString
    If DownloadURLtoFile(cell.Value,FolderString) Then
        cell.Offset(,3).Value = "Successfully downloaded"
    Else
        cell.Offset(,3).Value = "Error - no download"
    End If

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)