I am trying to copy the exact value of a cell from the web to an excel sheet. I have been able to do this using getelementbyid and getelementbytagname in order to drill down to the exact value that I wanted to pull from the website.
I did this before using code like this: Sheets("FOR COPY MACRO").Range("Z1").Value = ie.Document.getElementById("Fsc").getElementsByTagName("tr")(3).getElementsByTagName("td")(0).getElementsByTagName("div")(0).getElementsByTagName("INPUT")(0).Value
I am trying to do this on a webpage that doesn't have good id tags. Can I do the same thing but with getElementByName instead of getElementById? I am trying to do it as follows: Sheets("FOR COPY MACRO").Range("Z1").Value = ie.Document.getElementByName("frmCmdyListRfpSectn").getElementsByTagName("tr")(0).getElementsByTagName("td")(3).getElementsByTagName("input")(0).Value
However, this above code does not work. Is it possible to do what I am trying to do?
VBA macro copying exact cell value from web to excel
-
-
-
Re: VBA macro copying exact cell value from web to excel
Please post a link - as required by rule 4 - to your duplicate thread on stackoverflow.com and any other forums you've posted this question on. You should also post reciprocal links on those threads to all other threads you've posted this question on. Why? See http://www.excelguru.ca/content.php?184.
-
Re: VBA macro copying exact cell value from web to excel
Oops. I apologize. I'm a forum newbie. Thanks for letting me know of my mistake. Should I delete all but one of my requests? I won't do this in the future.
-
Re: VBA macro copying exact cell value from web to excel
There's no need to delete any of your other forum threads. On every thread where you've posted this question, post link(s) to your same question on other forum(s). So for example on this ozgrid thread please post a link to your stackoverflow thread, and on your stackoverflow thread please post a link to this ozgrid thread. Then anyone who might help can see if your question has already been answered and not waste their time.
-
Re: VBA macro copying exact cell value from web to excel
Thanks for doing that. Also, please use CODE tags when posting VBA code - see the rules.
There is no such method as getElementByName. It is getElementsByName, with an s.
It's difficult to help without the URL, but try this:
CodeSheets("FOR COPY MACRO").Range("Z1").Value = ie.Document.getElementsByName("frmCmdyListRfpSectn")(0).getElementsByTagName("tr")(0).getElementsByTagName("td")(3).getElementsByTagName("input")(0).Value
Instead of trying to drill down to the final element in one statement, get one element at a time and then it's easier to verify that you're referring to the correct element.
-
-
Re: VBA macro copying exact cell value from web to excel
Yes! That helped a lot. Especially your tip about verifying it. You're the best! Many thanks.
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!