I am VERY new to VBA and have been watching a ridiculous amount of youtube videos (specifically wise owl tutorials) and have searched here to try and find the answer to my question. I am writing a code to automate part of my job. I have the code to log in to a site that I can't share because I work with classified docs but I will share what I can. Here is the code so far...
Sub Login_and_click_link()
Dim IE As New SHDocVw.InternetExplorer
Dim HTMLDoc As MSHTML.HTMLDocument
Dim HTMLInput As MSHTML.IHTMLElement
Dim HTMLDiv As MSHTML.IHTMLElement
Dim HTMLAs As MSHTML.IHTMLElementCollection
Dim HTMLA As MSHTML.IHTMLAnchorElement
'Open Internet Explorer and Navigate to PDDA
With IE
.Visible = True
.Navigate "http://.TheWebsiteINeed.com"
End With
'Loop until PDDA page has fully loaded
Do While IE.ReadyState <> READYSTATE_COMPLETE
Loop
'Search DOM for element by ID and input username
Set HTMLDoc = IE.Document
Set HTMLInput = HTMLDoc.getElementById("userName")
HTMLInput.Value = Worksheets("sheet1").Range("letternumber").Text
'Search DOM for an element by ID and input password
Set HTMLInput = HTMLDoc.getElementById("Password")
HTMLInput.Value = Worksheets("sheet1").Range("letternumber").Text
'Search DOM for element by ID and click submit
Set HTMLInput = HTMLDoc.getElementById("submit")
HTMLInput.Click
'Navigate to the tab I need
??????
End Sub
There are two links on the page, each will take me to the same page that I need next. So whichever is easier to write code for you can use.
The link at the top is this(within a tr tag):
<span> class="topNavoff" style="cursor: hand;" onmouseover="window.status='Process
Management';this.className='topNavon';"
onmouseout="window.status='';this.className='topNavoff';"
onclick="setTask('pmMain');">Process</span>
The link at the bottom is this (within a p tag):
<span> class="contentSubtitleLink" id="process" style="cursor: hand;"
onmouseover="window.status='Process Management';" onmouseout="window.status='';"
onclick="setTask('pmMain');">Process</span>
Let me know if there is anything I can send to help make this more clear. ANY help would be GREATLY appreciated!