PDA

View Full Version : Solved: Download file from web



sujittalukde
07-12-2007, 05:28 AM
I have a code which downloads file from yahoo finance. It downloads the portfolio file from the yahoo finance. THe name of the url consists of name of stocks in the portfolio which can be found on the attached file.

Now my problem is if i add some more stocks in yahoo website portfolio, i need to update the code also. can this be fixed?

In the attached file i have given the address of url, user id and password.
Now if I add one more stock name to the yahoo portfolio, the code will not downlod new file until I change the url in macro code also. How this can be fixed so that even if I add a stock name to the portfolio, the code will always download updated file.

In case you need some more clarification do let me know.

Charlize
07-12-2007, 06:17 AM
Not sure if it's something like this you need. But I've made something a while ago. Here is the link of one of those threads. http://www.vbaexpress.com/forum/showthread.php?t=11743&highlight=yahoo Just add your stocknames to the list. Not sure if the one with ^ will work. This will fetch daily, weekly and monthly data until the day that you push the button.

sujittalukde
07-12-2007, 06:32 AM
Thanks Charlize, you did a great job. Actually I was also searching for the same for a long time. Thanks. I will continue this type of problem at an another post as I have some qwery also.
But for this post actually there is a difference. Your code downloads historical prices whereas the code in my problem is for downloading Portfolio file ( in csv format) from yahoo which shows todays value of stocks (Real time value when the market is open). I do some post downloading work also with the file so macro code is helping me a lot but the only problem is that when I add a stock at yahoo site , the file name get changed and so I need to modify the code also.

I think if you go through this you can solve this too!
More clarifications are given in the att file in my first post.

Charlize
07-12-2007, 07:24 AM
This version (use go_for_it) will get you passed the logpage of yahoo finances. Next thing is to loop through every link of the active internet document and look for a partial stringvalue of 'download' (with instr function). If you find such a link, you just have to navigate to that link. Not much time now, but if you are lucky, some of the wizards here will take a look at this.

Charlize
07-12-2007, 03:39 PM
This is your wet dream for tonight. I've put something together myself with a little info besides that seems to do the trick. Possible problem is the page loading after the push of the submit button on the inlogpage. I had to put a wait of 10 seconds (time to take a nip of your coffee before it gets cold) and the downloading seems to work if I change the portofolio items.

sujittalukde
07-13-2007, 05:59 AM
Oh Charlize, you are really great, really great. Last night I was thinking for the same. Though I dont have macro knowledge but I was thinking for the logical steps. My thought was that the macro code should copy the data to a sheet via web query and then the code shall take the list of stocks from that sheet say column A.
This was my thinking but you did it .
Thanks, Many Many Thanks.