(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
  Set myIEDoc = myIE.document

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

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

Set myIE = Nothing
End Sub

Leave a Reply

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