VBA:下载多个文件所需的更好的解决scheme

我正在使用代码从网站下载csv文件。 起初,我尝试了创buildInternetExplorer.Application等等的传统方法。这是最慢的方法。 后来我想通了selenium Wrapper的使用和创build下面的代码:

 'Option Explicit Sub ScripHistoryDownloader() Flag5 = 0 Dim selDriver As Object Dim URL As String, Scripcode As String Dim StartDate As String, EndDate As String Dim ScripHistPATH As String, DownloadedScripHistFILE As String, ScripHistFILE As String ScripHistPATH = "R:\DataStore\003__ScripHistory\" Scripcodez = "500010" ScripHistFILE = ScripHistPATH & Scripcodez & ".csv" StartDate = "01/01/1990" URL = "http://www.bseindia.com/markets/equity/EQReports/StockPrcHistori.aspx?expandable=7&scripcode=" & Scripcodez & "&flag=sp&Submit=G" ChromeDownloadsURL = "chrome://downloads/" Set selDriver = CreateObject("SeleniumWrapper.WebDriver") selDriver.Start "chrome", "http://www.google.com/" selDriver.Open URL selDriver.Type "id=ctl00_ContentPlaceHolder1_txtFromDate", StartDate selDriver.findElementById("ctl00_ContentPlaceHolder1_btnSubmit").Click selDriver.Click "id=ctl00_ContentPlaceHolder1_btnSubmit" selDriver.clickAndWait "ctl00_ContentPlaceHolder1_btnDownload" selDriver.Open ChromeDownloadsURL 'Checking if download is Completed. downloadChecker: Application.Wait (Now + TimeValue("0:00:05")) DownloadedSHFileName = selDriver.findElementByClassName("name").Text If DownloadedSHFileName = "" Then GoTo downloadChecker End If 'Finding out where the file is downloaded and moving it to the desired location. ChromeDownloadsHtml = selDriver.getHtmlSource PathStartPosition = InStr(ChromeDownloadsHtml, "file:///") PathStartPosition = PathStartPosition + 8 TempPathText = Mid(ChromeDownloadsHtml, PathStartPosition) PathEndPosition = InStr(TempPathText, "/" & Scripcodez) ScrambledPath = Left(TempPathText, PathEndPosition) DownloadedScripHistFILE = Replace(ScrambledPath, "/", "\") & DownloadedSHFileName selDriver.stop MoveOrRenameFile DownloadedScripHistFILE, ScripHistFILE Set selDriver = Nothing Flag5 = 1 EndOfBhavCopyDownloader: End Sub 'Function to Move or rename a file or Folder Sub MoveOrRenameFile(SourcePath As String, DestinationPath As String) Name SourcePath As DestinationPath End Sub 

代码运行完全正常。 我使用这个代码每天下载大约3000个文件,每当我的电脑打开时就会触发。 我的问题是,无论何时这个代码被触发铬浏览器popup,也是一个cmd窗口。我不希望这种popup窗口发生在使用铬。 没有办法隐藏浏览器和cmd窗口,就像我们在InternetExplorer.Application使用ie.Visible = False隐藏IE一样。 还打开浏览器,导航…使过程非常缓慢。 是否有可能使用Microsoft.XMLHTTP对象执行上述代码操作? 我已经使用(在示例的帮助下) Microsoft.XMLHTTP对象,但我没有填写表单生成一个文件,然后下载它(我没有太多的知识使用它)…任何人都可以显示我的方式? 任何帮助表示赞赏。

注意:发布的代码是来自我的项目模块: 我的整个项目作为参考