I'm running into a problem to automate a process where my program can download a specified file. I have my VBA code point to the file but when the SaveAs box comes up I don't know what to do from that point on. Please someone help me!!
I'm running into a problem to automate a process where my program can download a specified file. I have my VBA code point to the file but when the SaveAs box comes up I don't know what to do from that point on. Please someone help me!!
could you be a little more specific about 'file' - html, image, pdf??? And, are you using the InternetExplorer.Application Object, or sendkeys.... ??
.02
Stan
Basically what happens is i have the internetexplorer object go to a download link. The link is to a .CSV file, in which then a file download box pops up, my options are to open it, save it, or cancel. What i want the program to do is click on save and save to a specified location. Not sure if i should use windows API for this one or if there is a better method.
Is this a secure site? I would use CreateObject("MSXML2.XMLHTTP") especially if you have a url reference to the .csv file.
Stan
'pseudo-code oHTTP = CreateObject("MSXML2.XMLHTTP") cURL = "http://www.mysite/myfile.csv oHTTP.open "GET", cURL, False oHTTP.send "" oStream = CreateObject("ADODB.Stream") oStream.Type = 0 'ascii oStream.Open oStream.Write oHTTP.responseBody oStream.SaveToFile "mycsvfile" ,2 oStream.close oStream=Nothing oHTTP=Nothing
well actually the link is something like this....
"https://workbench.mellon.com/cr/crControl/ViewReportOutput?documentID=4130669&transformType=csvWithHeader&reportInsta nceId=5480739&downloadType=download"
So i don't think i can use the xml commponent, any other suggestions?
That is why I asked 'Is it a secure site' - you can use an HTTP POST rather than GET w/login and pwd info.
Stan
I'm not sure if i am following you??
In my experience, unless HTTP protocol is turned off by the server, either binary or ascii files can be obtained. If I just try to navigate to the URL you supplied I end up with a login screen. You might try something basic likeOriginally Posted by bkholy
where userid and password are what you use to login. Worse case you cannot connect and myfile will contain nothing; or it will contain html code with an error, or the downloadType=Download parameter forces the saveas box.myfile = "C:\temp\test.txt" cURL =https://workbench.mellon.com/cr/crCo...dType=download ;note the object change, this has less overhead than ;msxml2.http WinHttpReq = CreateObject("WinHttp.WinHttpRequest.5.1") WinHttpReq.SetCredentials "userid", "password", "" WinHttpReq.Open("GET", cURL, False) WinHttpReq.Send "" oStream = CreateObject("ADODB.Stream") oStream.Type = 0 'ascii oStream.Open oStream.Write WinHttpReq.responseText oStream.SaveToFile myfile ,2 oStream.close oStream=Nothing WinHttpReq=Nothing
It is difficult from the outside of https to diagnose what is on the inside.
Stan