VBA to open/click hypertext link on a webpage

yuyyp445

New Member
Joined
Aug 4, 2017
Messages
6
I am very green to VBA. I learned online by reading through forums and watching YouTube. So please be descriptive in your response. Or just respond bc I need help lol

So I am using code below to navigate to a company site and logging on. This works fine and takes me to homepage. Now I am stuck. I need to open/click on a hypertext link. Technically I need to click hypertext (id=Link0) which drops down another hypertext (id=Link0_0) which I need to click to open a new window. IDK if it is framing, *******, or some other function, but I am unable to use .Click, .getElementsByTagName to open hypertext. Maybe I just don't know how to code those properly? There are several hypertext options formatted on the left-hand side of the screen and are scripted as parent and child nodes. Please advise on the simplest code to achieve this. Below is the website code that has the hypertext elements I need to open.


HTML:
<DIV class=mainMenuCont><DIV id=node0 class=mainMenuTopNode>
<TABLE>
<TBODY>
<TR>
<TD vAlign=top><IMG style="HEIGHT: 20px; WIDTH: 20px" src="/images/themes/themesswanblue/default.png"></TD>
<TD><SPAN class=mainMenuNode1></SPAN><A *******="openMenuNode('0');return false" id=Link0 href="#" name=0>General Cargo</A></TD></TR></TBODY></TABLE></DIV>
<DIV id=nodeChild0 class=mainMenuChildCont style="DISPLAY: none; VISIBILITY: hidden">
<DIV id=node0_0 class=mainMenuChildNode>
<DIV class=mainMenuNode2><A id=Link0_0 href="/GC3/glog.webserver.finder.FinderServlet?ct=1800184983&query_name=glog.server.query.order.OrderReleaseQuery&finder_set_gid=NAM.GC_US_PPS_REQ_SUBMITTED" name=Link0_0 target=mainBody>Create New Request</A></DIV>
<DIV id=nodeChild0_0 class=mainMenuChildCont style="DISPLAY: none; VISIBILITY: hidden"></DIV></DIV></DIV>
<DIV id=node1 class=mainMenuTopNode>

_________________________________

Code:
Sub TMSconnect()
Dim ie As Object
Set ie = CreateObject("internetexplorer.application")
With ie
.Visible = True
.navigate "https://tms.nam.slb.com/GC3/jsp/login.jsp"
Do
DoEvents
Loop Until ie.readyState = 4
ie.document.getElementById("username").Value = "xxxxx"
ie.document.getElementById("userpassword").Value = "yyyyyy"
ie.document.getElementById("Submit").Click
Do
DoEvents
Loop Until ie.readyState = 4
End With
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top