Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 367
Default Open file from website, where filename changes

We were automatically downloading a spreadsheet from the web, but now the
site has begun re-naming this spreadsheet with specific names.

Before we were using:
Workbooks.Open
"http://investor.shareholder.com/common/download/download.cfm?companyid=BHI&fileid=309891&filekey=4 599F87A-DAE4-4912-A4E1-6E7A3B928F61&filename=US_Rig_Report_.xls"

Which used to work, but now they change the file ID, filekey and date. Here
is an example of the new file name
http://investor.shareholder.com/comm...9revised. xls

here is the website where the link is located:
http://investor.shareholder.com/bhi/...s/rc_index.cfm

How might we automate opening this file as we were before?

Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
ron ron is offline
external usenet poster
 
Posts: 118
Default Open file from website, where filename changes

On Jan 6, 3:26*pm, Jason wrote:
We were automatically downloading a spreadsheet from the web, but now the
site has begun re-naming this spreadsheet with specific names.

Before we were using:
Workbooks.Open
"http://investor.shareholder.com/common/download/download.cfm?companyi..."

Which used to work, but now they change the file ID, filekey and date. *Here
is an example of the new file namehttp://investor.shareholder.com/common/download/download.cfm?companyi...

here is the website where the link is located:http://investor.shareholder..com/bhi...s/rc_index.cfm

How might we automate opening this file as we were before?

Thanks!


Jason...Does the file of interest always have the phrase "North
American Rotary Rig Count - Current" in its title? Is so, the
following should code do it...Ron

Sub Rig_Data()
' Assign the source code behind the webpage of interest to a variable
my_url = "http://investor.shareholder.com/bhi/rig_counts/
rc_index.cfm"
Set my_obj = CreateObject("MSXML2.XMLHTTP")
my_obj.Open "GET", my_url, False
my_obj.send
my_var = my_obj.responsetext
Set my_obj = Nothing

' Locate the phrase "North American Rotary Rig Count - Current"
my_phrase = "North American Rotary Rig Count - Current"
loc_1 = InStr(1, my_var, my_phrase, vbTextCompare)

' and now extract the url of interest
loc_2 = InStrRev(my_var, ".xls", loc_1, vbTextCompare)
loc_3 = InStrRev(my_var, "href=", loc_2, vbTextCompare)

my_url = Mid(my_var, 6 + loc_3, (3 + loc_2 - 5 - loc_3))
my_url = "http://investor.shareholder.com" & my_url

' open the file
Workbooks.Open my_url
End Sub
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 367
Default Open file from website, where filename changes

Perfect! Exactly what we were looking for.

Thanks!
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Open FileName For Input As #FileNum2 - - - File Already Open! [email protected] Excel Programming 1 October 28th 08 02:47 PM
Find filename of open file Ian[_4_] Excel Programming 5 April 23rd 08 06:10 PM
Open File based on filename in cell TOMB Excel Programming 4 April 26th 07 07:55 PM
want to download csv file from website and need to open in Excel. Jeff Excel Discussion (Misc queries) 2 January 17th 06 05:35 PM
Can't open XL file on website in IE6 edger Excel Discussion (Misc queries) 0 December 20th 04 09:59 PM


All times are GMT +1. The time now is 02:05 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"