(Solved) – VBA code to download data from website under some condition

(solved)-–-vba-code-to-download-data-from-website-under-some-condition

I need to download gold price from this website https://eximbank.com.vn/home/Static/Gold.aspx under 2 condition (date and table number)as below. This code debug with run time error 438 “Object doesn’t support this property or method” when I choose date and table number. Could anyone tell me why it is. Many thanks in advance!

  Sub Eximbank()
  Dim myIE As New InternetExplorer
  Dim myIEDoc As HTMLDocument
  myIE.Visible = False
  myIE.navigate "https://eximbank.com.vn/home/Static/Gold.aspx"
  Do While myIE.readyState <> 4 Or myIE.Busy
  DoEvents
  Loop
  Set myIEDoc = myIE.document

   ' Choose Date and Table number
  myIEDoc.getElementsByName("CalControl1$TextBox1").Value = "14/04/2020"
  myIEDoc.getElementsByName("ddlQuoteCount").Value = "19"
  myIEDoc.getElementsByName("ImageButton1").Click

 'Download data to active workbook
ActiveWorkbook.Sheets("Sheet1").Range("A1") = Now
ActiveWorkbook.Sheets("Sheet1").Range("A1")=myIEDoc.getElementsById("GoldRateRepeater_lblCSHBUYRT_0")(0).getElementsByTagName("td")(0).innerText
ActiveWorkbook.Sheets("Sheet1").Range("B1") = myIEDoc.getElementsById("GoldRateRepeater_lblCSHSELLRT_0")(0).getElementsByTagName("td")(1).innerText

 myIE.Quit
Set myIE = Nothing
End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *