Results 1 to 4 of 4

Vba to extract data from a web site

Threaded View

  1. #1
    Registered User
    Join Date
    08-28-2012
    Location
    wisbech england
    MS-Off Ver
    Excel 2003
    Posts
    7

    Vba to extract data from a web site

    Hi all , this is my first post I hope I get across my idea clearly ( my first web VBA please be gentle ):

    What I want to achieve:

    1) open a web page http://www.bmreports.com/bwh_Mid.htm
    2) insert date and period in the text box and click "go"
    3) once the data is displayed I need to import them in eirther excel or access

    I found lot of problem in inserting data and periods in the textbox , unfortunately the web queries are not displayed in the browser
    Below the code I have used :
    Sub GetMarketPrice()
    Dim ie As Object, ipf As Object
    Dim strURL As String
    Dim tries
    
    Set ie = CreateObject("InternetExplorer.Application")
    strURL = "http://www.bmreports.com/bwh_Mid.htm"
    Dim ieObj As HTMLInputElement
    ie.Navigate strURL
    While ie.busy
      DoEvents  'wait until IE is done loading page.
    Wend
    
    
    'Set ieObj = ie.document.All("param0")
    'ieObj.Value = "2012-01-01" 'run-time error -91
    
    
    '###################################################################
    'enter date
    Set ipf = ie.document.getElementById("param0")
    ipf.Value = "2011-01-05" 'fill in the text box (here error)
    ie.document.All("param0").Value = "2011-01-01"
    '###################################################################
    
    '################################################################
    'I have also tried this: But againd failed
    ''Set ipf = ie.Document.getElementbytagname("param0")
    ''ipf.Value = "2011-01-05" 'fill in the text box
    '''Set ipf = IE.document.getElementByName("param0")
    ''ipf.Value = "2011-01-05" 'fill in the text box
    '###################################################################
    
    End Sub
    below the web code:
    HTML Code: 
    Last edited by Leith Ross; 08-28-2012 at 04:24 PM. Reason: Addec Code and HTML Tags

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1