VBA and IE

TNTScrub

New Member
Joined
Jan 7, 2021
Messages
12
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hello Geniuses,
I've been lurking on this forum for many moons trying to learn how to be vba useful but today I'm vba useless. Please help me because I really don't want to do this manually. I hope I can describe this correctly. I have a spread sheet with ID numbers in column A. I have a code that opens an internal website, logs me in, searches the ID and clicks the search button. This brings up the identifying information for that ID. At the bottom of that page is a link labeled "View/Update". This link has no "id" and I cant figure out how to make my code click it. I'm baffled. I obviously have a ton more to do after getting that to work but I'm trying to take this one step at a time.


Sub LOGIN()
Dim ie As InternetExplorer
Dim i As Variant
Set ie = New InternetExplorer
ie.Visible = True
ie.Navigate2 "My Website"
Do While ie.Busy: DoEvents: Loop
Do Until ie.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
ie.Document.all("TextBox_UserName").Value = "Username"
ie.Document.all("TextBox_LoginPassword").Value = "Password"
ie.Document.all("Button_Login").Click
Do While ie.Busy: DoEvents: Loop
Do Until ie.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
ie.Navigate2 "http://mi-inet01.mimc.com/apps/PM/EquipmentManagement/equipment/Master.aspx"
Do While ie.Busy: DoEvents: Loop
Do Until ie.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
ie.Document.all("txtNumber").Value = ActiveCell.Value
ActiveCell.Offset(1, 0).Select
ie.Document.all("butQuickSearch").Click

Dim ele As Object
For Each ele In ie.Document.getElementsByTagName("href")
If ele.Value = "View/Update" Then ele.Click: Exit For
Next

End Sub


Clearly I don't know what I'm doing.

1610052775516.png

This is the relevant Element info.
 

Some videos you may like

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Worf

Well-known Member
Joined
Oct 30, 2011
Messages
4,096
Welcome to the Board

The <a> tag defines a hyperlink, which is used to link from one page to another.

The most important attribute of the <a> element is the href attribute, which indicates the link's destination.

So you should use:

document.getElementsByTagName("a")
 

Watch MrExcel Video

Forum statistics

Threads
1,122,995
Messages
5,599,256
Members
414,299
Latest member
thenewworld

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
Top