Engineer123456
New Member
- Joined
- Dec 20, 2019
- Messages
- 3
- Office Version
- 365
- Platform
- Windows
Hello,
I am trying to write a VBA code to get some info from a website to bring into excel. I am able to go to the website, click the login button, enter by login information, click the sign in button, but then I am stuck trying to close the 'Welcome Popup" on the main page. I should be able to close this welcome popup by writing code to either click the "continue" button or the "exit" button on the welcome popup. The Java code for each of these buttons will be posted below my VBA code. See my VBA code below:
Note: I am currently not getting any errors in excel from running this code, but it will not close the welcome popup.
Sub ASCElogin()
Dim objIE As Object
Dim UserName As String
Dim Password As String
UserName = Range("G7").Value
Password = Range("G8").Value
'Open Internet Explorer
Set objIE = CreateObject("InternetExplorer.Application")
With objIE
.AddressBar = False
.StatusBar = False
.MenuBar = False
.Toolbar = 0
.Visible = True
.navigate "ASCE 7 Hazard Tool"
Do Until Not objIE.Busy And objIE.readyState = 4
DoEvents
Loop
End With
'Clicking Login Button then goes to 'sign in' page
For Each HTMLInputElement In objIE.document.getElementsByClassName("waves-effect waves-light btn blue darken-3")
If HTMLInputElement.className = "waves-effect waves-light btn blue darken-3" Then
HTMLInputElement.Click
Exit For
End If
Next HTMLInputElement
Do Until Not objIE.Busy And objIE.readyState = 4
DoEvents
Loop
'Entering UserName
For Each HTMLInputElement In objIE.document.getElementsByName("ctl00$main$LoginTextBox")
If HTMLInputElement.Name = "ctl00$main$LoginTextBox" Then
HTMLInputElement.Value = UserName
Exit For
End If
Next HTMLInputElement
'Entering Password
For Each HTMLInputElement In objIE.document.getElementsByName("ctl00$main$PasswordTextBox")
If HTMLInputElement.Name = "ctl00$main$PasswordTextBox" Then
HTMLInputElement.Value = Password
Exit For
End If
Next HTMLInputElement
'Clicking Sign-In button and go to main page
For Each HTMLInputElement In objIE.document.getElementsByName("ctl00$main$SubmitButton")
If HTMLInputElement.Name = "ctl00$main$SubmitButton" Then
HTMLInputElement.Click
Exit For
End If
Next HTMLInputElement
Do Until Not objIE.Busy And objIE.readyState = 4
DoEvents
Loop
'Closing Welcome Popup - this currently does not close the welcome popup - but I do not get any errors
For Each HTMLInputElement In objIE.document.getElementsByClassName("details-popup-close-icon")
If HTMLInputElement.className = "details-popup-close-icon" Then
HTMLInputElement.Click
Exit For
End If
Next HTMLInputElement
End Sub
Java Code:
For the "Continue" button. Continue button is the last line of code below:
<div class="flex flex-column flex-justify-center align-items-center margin-vertical" data-reactid=".0.1.0.4.0.1.1">
<a class="waves-effect waves-light btn blue darken-3" data-reactid=".0.1.0.4.0.1.1.0">Continue</a>
For the exit button in top right corner of the welcome popup. Exit button is last line of code below:
<div class="popup-header blue darken-3 welcome-header" data-reactid=".0.1.0.4.0.0">
<span data-reactid=".0.1.0.4.0.0.0">ASCE 7 Hazard Tool</span>
<span class="details-popup-close-icon" data-reactid=".0.1.0.4.0.0.1"></span>
Any help would be greatly appreciated!
Thanks,
I am trying to write a VBA code to get some info from a website to bring into excel. I am able to go to the website, click the login button, enter by login information, click the sign in button, but then I am stuck trying to close the 'Welcome Popup" on the main page. I should be able to close this welcome popup by writing code to either click the "continue" button or the "exit" button on the welcome popup. The Java code for each of these buttons will be posted below my VBA code. See my VBA code below:
Note: I am currently not getting any errors in excel from running this code, but it will not close the welcome popup.
Sub ASCElogin()
Dim objIE As Object
Dim UserName As String
Dim Password As String
UserName = Range("G7").Value
Password = Range("G8").Value
'Open Internet Explorer
Set objIE = CreateObject("InternetExplorer.Application")
With objIE
.AddressBar = False
.StatusBar = False
.MenuBar = False
.Toolbar = 0
.Visible = True
.navigate "ASCE 7 Hazard Tool"
Do Until Not objIE.Busy And objIE.readyState = 4
DoEvents
Loop
End With
'Clicking Login Button then goes to 'sign in' page
For Each HTMLInputElement In objIE.document.getElementsByClassName("waves-effect waves-light btn blue darken-3")
If HTMLInputElement.className = "waves-effect waves-light btn blue darken-3" Then
HTMLInputElement.Click
Exit For
End If
Next HTMLInputElement
Do Until Not objIE.Busy And objIE.readyState = 4
DoEvents
Loop
'Entering UserName
For Each HTMLInputElement In objIE.document.getElementsByName("ctl00$main$LoginTextBox")
If HTMLInputElement.Name = "ctl00$main$LoginTextBox" Then
HTMLInputElement.Value = UserName
Exit For
End If
Next HTMLInputElement
'Entering Password
For Each HTMLInputElement In objIE.document.getElementsByName("ctl00$main$PasswordTextBox")
If HTMLInputElement.Name = "ctl00$main$PasswordTextBox" Then
HTMLInputElement.Value = Password
Exit For
End If
Next HTMLInputElement
'Clicking Sign-In button and go to main page
For Each HTMLInputElement In objIE.document.getElementsByName("ctl00$main$SubmitButton")
If HTMLInputElement.Name = "ctl00$main$SubmitButton" Then
HTMLInputElement.Click
Exit For
End If
Next HTMLInputElement
Do Until Not objIE.Busy And objIE.readyState = 4
DoEvents
Loop
'Closing Welcome Popup - this currently does not close the welcome popup - but I do not get any errors
For Each HTMLInputElement In objIE.document.getElementsByClassName("details-popup-close-icon")
If HTMLInputElement.className = "details-popup-close-icon" Then
HTMLInputElement.Click
Exit For
End If
Next HTMLInputElement
End Sub
Java Code:
For the "Continue" button. Continue button is the last line of code below:
<div class="flex flex-column flex-justify-center align-items-center margin-vertical" data-reactid=".0.1.0.4.0.1.1">
<a class="waves-effect waves-light btn blue darken-3" data-reactid=".0.1.0.4.0.1.1.0">Continue</a>
For the exit button in top right corner of the welcome popup. Exit button is last line of code below:
<div class="popup-header blue darken-3 welcome-header" data-reactid=".0.1.0.4.0.0">
<span data-reactid=".0.1.0.4.0.0.0">ASCE 7 Hazard Tool</span>
<span class="details-popup-close-icon" data-reactid=".0.1.0.4.0.0.1"></span>
Any help would be greatly appreciated!
Thanks,