Using URLDownloadToFile to Download a... "secondary" URL?

Stang70Fastback

Registered User.
Local time
Today, 08:09
Joined
Dec 24, 2012
Messages
132
Hey guys. Quick question. I was initially using the URLDownloadToFile function to download a .csv file from an employee scheduling website. Everything was working fine, but then we discovered that the URL I was using (provided by the site's tech support staff) did not include any as-of-yet unassigned shifts. We need those. A quick email to them and they replied back that there was no direct URL that would allow us to download both assigned and UNassigned shifts in one .CSV file, but they provided what, to me, appears to be a, shall we say half-@$$ed solution. What they want me to do is first call ONE url, which if you enter it in a web browser, opens a page listing ALL of our assigned and un-assigned shifts. Once I do that, I can call a second URL ending in .CSV that will download them appropriately.

So it seems I need to "set up" the download by first calling one URL before I can download using the second. I am not sure how to implement this in URLDownloadToFile. I tried embedding a WebBrowserControl that would navigate to the first URL before the function was called, but they don't seem to "connect" because the file I end up downloading is as though I didn't call the first URL at all. I'm not sure how it works on their end, because both URLs use a Static ID to avoid having to log in, so I would assume that as long as someone SOMEWHERE browsed to that first URL correctly using that same static ID, that the second URL should download the correct file no matter where in the world you were doing it from, but that appears not to be the case.

It looks like, for some reason, you have to use the same method on the same computer for BOTH URLs if the second one is to work properly. Does anyone have any suggestions at all for how to implement this? I'm pulling my hair out over what would normally be a really simple issue, but has now become complicated because of this intermediate URL... :banghead:

EDIT: This won't help, since you can't use these URLs without an SID, but just to give you an idea of what I am doing:

URL I have to call to "set up" the download (displays the week's shifts for the date at the end of the URL):

https://www4.whentowork.com/cgi-bin/w2wD.dll/mgrschedule?SID=1234567890&Date=02/19/2013

URL I can then use to download that week as a CSV file:

https://www4.whentowork.com/cgi-bin...Y&F12=Y&F13=Y&F14=Y&F15=Y&Filename=EXPORT.csv
 
Last edited:
So does anyone have any suggestions for this or have I pretty much come across something that's impossible to do? This is literally the last issue keeping me from presenting this whole project to the IT department where I work and starting to implement it!
 
Have you tried just opening the web page first with something like the following:

Dim ie As Object
Set ie = CreateObject("InternetExplorer.application")
ie.Visible = True
ie.Navigate "www....."
Do Until ie.ReadyState = 4
Loop

'Your code for donwloading the .csv here
 
Thanks for the reply! You'll never believe it but I just figured this out last night, and it works like a charm!
I'm still not sure why this method works, yet calling the URL in an embedded web object does not, but I don't care at this point!
 

Users who are viewing this thread

Back
Top Bottom