0

I am new to programming with Microsoft Visual Basic and am trying to create a program that will put co-ordinates into an image database website.

I am trying to put numbers into a specific space on a website.

The place that I would like to input a number for right ascension, doesn't have a specific ID when I inspect it on the website, so I tried getElementsByTagName, however, this isn't working.

I also looked to find an ID of a larger section of the HTML code as specified here: How to access HTML element without ID?, however that isn't working either.

Sub MovesData()
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")

IE.Visible = True
IE.navigate "http://wsa.roe.ac.uk:8080/wsa/getImage_form.jsp? programmeID=&database=UKIDSSDR11PLUS&ra=&dec=&sys=J&filterID=all&xsize=1&ysize=1&obsType=object&frameType=stack&mfid=&fsid=&name="

Do While IE.Busy
    Application.Wait DateAdd("s", 1, Now)
Loop

IE.document.getElementsByTagName("ra").Value = "23"


End Sub

The HTML code for the specific line is:

<input type="text" name="ra" value="" size="15">

The section of HTML code is:

<td nowrap="" align="right"><b>RA</b> or <b>Galactic Long.:</b></td>
<td>
<input type="text" name="ra" value="" size="15">
<td><input type="text" name="ra" value="" size="15"></td>

I expect the output to be 23 in the right ascension box but it is just blank and there is a run time error 438 "Object doesn't support this property or method". Any help would be greatly appreciated!

JJJ
  • 32,902
  • 20
  • 89
  • 102
  • "tagname" is the name of the element on the page, i.e. "div" or "input" Note also that the function is plural. When searching by ID there should in theory be only one match because ID's are supposed to be unique, however there can, and usually will be LOTS of matching elements for any given tag name. Show the segment of HTML code in question in your original post. – Bill Hileman Jul 04 '19 at 19:52
  • Yes, there is more than one match for name in the HTML code. Is the code that I added in what you were looking for or would you like to see the part that has a repeated name section? What can you use to identify the space without the unique ID? – Cosmocomputer Jul 05 '19 at 07:56
  • If you retrieve elements by tagname, the result should be assigned to an array, after which you should better be able to determine which one is the one you want, but a better method would be to retrieve by xpath. I use Selenium for Java. Even though I code in VB6, I've never worked with HTML documents with it, so I don't know if VB6 has a corresponding way, like Java Selenium does, to find elements by xpath, but if it does, that's the way to go, and just the segment containing your element should be sufficient for now for display here. – Bill Hileman Jul 05 '19 at 13:11
  • Thank you. I will see if I can find an equivalent to Selenium to use. – Cosmocomputer Jul 08 '19 at 06:45

0 Answers0