Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
vba7中的对象浏览器不显示WebClient对象成员_Vba_Excel - Fatal编程技术网

vba7中的对象浏览器不显示WebClient对象成员

vba7中的对象浏览器不显示WebClient对象成员,vba,excel,Vba,Excel,我需要从URI自动下载并保存一个文件。我想我可以使用“urlmon”库中的URLDownloadToFile,但我想使用WebClient.DownloadFile方法 我希望这是一次轻松愉快的谈话,但由于其他原因,我无法在VBA 7 IDE中查看或使用WebClient类的成员。我已经引用了.Net 2 framework的System.tlb,并且能够看到System.Net命名空间中的类,但是许多类的成员不可见,我无法在代码中使用它们 尝试使用以下代码时出现编译错误: Dim Downlo

我需要从URI自动下载并保存一个文件。我想我可以使用“urlmon”库中的URLDownloadToFile,但我想使用WebClient.DownloadFile方法

我希望这是一次轻松愉快的谈话,但由于其他原因,我无法在VBA 7 IDE中查看或使用WebClient类的成员。我已经引用了.Net 2 framework的System.tlb,并且能够看到System.Net命名空间中的类,但是许多类的成员不可见,我无法在代码中使用它们

尝试使用以下代码时出现编译错误:

Dim Downloader as New System.WebClient

Downloader.DownloadFile("uri","filename")
也许我没有注册要在VBA中使用的.Net类,因此出现了问题,但是;我的项目中引用的
System.dll
位于
C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.tlb

这让我更加困惑。此外,如果有人能够详细说明在VBA 7中引用.Net Framework库的过程,这将非常有帮助


提前谢谢

我建议使用MSXML库代替.Net库。您可以通过单击“工具”-->“引用…”并选中“Microsoft XML,x.x”旁边的框(其中x.x是最新版本),将其添加到IDE中的VBA中

以下是您可以运行的快速测试:

Public Sub Downl()
    Dim xhttp As MSXML2.XMLHTTP
    Set xhttp = New MSXML2.XMLHTTP

    Dim oFile As Integer
    oFile = FreeFile()
    Open CurrentProject.Path & "\test.png" For Binary Access Write As oFile

    Dim bdata() As Byte

    With xhttp
        .Open "GET", "https://www.google.com/images/srpr/logo11w.png", False
        .send
        bdata = .responseBody
        Put oFile, 1, bdata
    End With

    Close oFile
End Sub

如果您想在VBA项目中使用.Net库,.@Blackhawk:谢谢您发布该链接:)该链接刚从我发布的链接中删除:)