Hey All,
So I have this code which I have copied and pasted from various threads on this site,
Now I am wondering see at the end instead of using send keys could a code be put in which says Find words "My Clients" and click enter, then get a message box that comes up and says what client?
The name could then be entered in here which excel could find on that page and then press the select button on the same row as that client.
Does that make sense, I am now sure what the code is of asking excel to find a series of words on the website and press enter after.
Could anyone please help?
Thanks
So I have this code which I have copied and pasted from various threads on this site,
Code:
'Need reference to Microsoft HTML Object Library. Select this in Tools - References in VB editor.
Option Explicit
Public Enum IE_READYSTATE
Uninitialised = 0
Loading = 1
Loaded = 2
Interactive = 3
complete = 4
End Enum
Sub AlphaTest()
Const cURL = "[URL="https://sedsh04.sedsh.gov.uk/esd/xsql/sys_getLogin.xsql"]Web Address"[/URL]
Const cUserID = "XXXX" 'REPLACE XXXX WITH YOUR USER ID
Const cPwd = "YYYY" 'REPLACE YYYY WITH YOUR PASSWORD
Dim ie As Object
Dim doc As HTMLDocument
Dim PageForm As HTMLFormElement
Dim UserIdBox As HTMLInputElement
Dim PasswordBox As HTMLInputElement
Dim FormButton As HTMLInputButtonElement
Dim Elem As IHTMLElement
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.navigate cURL
'Wait for initial page to load
Do While ie.busy Or Not ie.readyState = IE_READYSTATE.complete: DoEvents: Loop
Set doc = ie.document
'Output HTML tags to debug window
Debug.Print "Login page: " & ie.LocationURL
For Each Elem In doc.all
'Debug.Print Elem.tagName
Next
'Get the only form on the page
Set PageForm = doc.forms(0)
'Get the User Id textbox
'< input class="TextBox" maxlength="15" name="UserName" size="12">
Set UserIdBox = PageForm.elements("UserName")
'Set the User Id
UserIdBox.Value = cUserID
'Get the password textbox
'< input class="TextBox" type="password" maxlength="10" name="Password" size="12">
Set PasswordBox = PageForm.elements("Password")
'Set the password
PasswordBox.Value = cPwd
'Submit the form (like clicking the 'Submit' button) to navigate to next page
PageForm.submit
'Wait for the new page to load
Do While ie.busy Or Not ie.readyState = IE_READYSTATE.complete: DoEvents: Loop
'Get the HTML document of the new page
Set doc = ie.document
'Output HTML tags to debug window to prove this is the new page
Debug.Print "Terms of Use page: " & ie.LocationURL
For Each Elem In doc.all
'Debug.Print Elem.tagName
Next
ie.Visible = True
'Send logg-on information!
'May need additional SendKeys as needed?
'Determine by the actual key-strokes needed!
SendKeys "(TAB)", True
SendKeys "{TAB}", True
SendKeys "(ENTER)", True
Application.Wait (Now + TimeValue("0:00:02"))
ActiveWindow.WindowState = xlMaximized
End Sub
Now I am wondering see at the end instead of using send keys could a code be put in which says Find words "My Clients" and click enter, then get a message box that comes up and says what client?
The name could then be entered in here which excel could find on that page and then press the select button on the same row as that client.
Does that make sense, I am now sure what the code is of asking excel to find a series of words on the website and press enter after.
Could anyone please help?
Thanks