I have an issue with a Macro I am trying to write to enable the following to happen:
A sheet is populated with the login information of a number of people who have access to a website.
Running the macro opens the website in IE, logs into the admin area of the site and open a search screen.
It then copies the first users details into the relevant area and presses a filter button
The relevant persons name is populated into a list with a hyperlinked piece of text which can be clicked to go through to the users details.
Due to the nature of the setup of the site, I don’t seem to be able to ascertain what code I need to use to click the hyperlinked piece of text so that the rest of the macro can do as needed. The text as it appears on the screen has an ID of ctl00_ContentPlaceHolder1_gridResults
But as the hyperlink that sits under it, is dynamic and changes dependant on whatever is entered into it and the results obtained, I cant work out what I need to enter to get it to click on the link. Clicking the text manually and then running the rest of the macro allows it to work fine, but I would like to automate the whole thing if possible.
Can you help?
Sub PauseUsers()
Dim email As String, password As String
Dim appIE As InternetExplorer
Dim rowNum As Long
Dim i As Integer
Dim txt As String, link As String
Dim ieDoc As Object
Set appIE = New InternetExplorer
email = "login email details"
password = "password details”
With appIE
.navigate "Website login screen address"
.Visible = True
Do While appIE.Busy
Application.Wait DateAdd("s", 1, Now)
Loop
.document.getElementById("textboxUsername").Value = email
.document.getElementById("textboxPassword").Select
.document.getElementById("textboxPassword").Value = password
.document.getElementById("buttonLogin").Click
Do While appIE.Busy
Application.Wait DateAdd("s", 1, Now)
Loop
.navigate "Website admin address"
Do While appIE.Busy
Application.Wait DateAdd("s", 1, Now)
Loop
.navigate "Admin area user search page address"
Do While appIE.Busy
Application.Wait DateAdd("s", 1, Now)
Loop
rowNum = 2
Do While Sheets("Combined").Cells(rowNum, 1).Value <> ""
.document.getElementById("rbtnTypeBoth").Click
.document.getElementById("tbEmail").Value = Sheets("Combined").Cells(rowNum, 1).Value
.document.getElementById("ContentPlaceHolder1_rblFilterRights_0").Click
.document.getElementById("ContentPlaceHolder1_btnFilter").Click
Application.Wait (Now + TimeValue("0:00:05"))
.document.getElementById("ctl00_ContentPlaceHolder1_gridResults").Click
'Macro will pause here, user will need to click View link on page and then Account and Contact Details then press play on Macro
.document.getElementById("radiobuttonStatusPaused").Click
.document.getElementById("textboxPausedReason").Select
.document.getElementById("textboxPausedReason").Value = Sheets("Combined").Cells(rowNum, 2).Value
.document.getElementById("btnSave").Click
.navigate "Website admin page"
Do While appIE.Busy
Application.Wait DateAdd("s", 1, Now)
Loop
rowNum = rowNum + 1
Loop
.Quit
End With
Exit Sub
incorrectLogin:
validateLogin = "Invalid login, please try again"
Resume
End Sub
Display More