VBA Webpage search

Fyte101

New member
Local time
, 23:32
Joined
Oct 30, 2024
Messages
1
Thank you in advance for any help given. I am trying to open an intranet page and then search on that page for information which is contained in a text box (txtMan) on a form.
Issue: The search is not happening on the opened webpage but on the MS Access form and any "setfocus" line is not working. Also I can not figure out how to return a message if text is found versus text not found.

Private Sub cmdSearch_Click()

On Error GoTo Error_cmdSearch

Dim strHyperlink As String

strHyperlink = Me.hypSearch
Application.FollowHyperlink strHyperlink, , True

If Len(Me.txtMan.Value & vbNullString) > 0 Then

SendKeys "^f", False
SendKeys Me.txtMan.Value, False
SendKeys "{ENTER}", False
SendKeys "{ESC}", False

End If

''**************************************************
' If statement based on returned value from search
' If true
' MsgBox "Text found on the website"
'Else
'MsgBox "Text not found on the website"
'End IF
''**************************************************

Exit_cmdSearch:
Exit Sub

Error_cmdSearch:
MsgBox Err & ": " & Err.Description
Resume Exit_cmdSearch

End Sub
 
Hi. Welcome to AWF!

Perhaps it would be better to avoid using SendKeys and perhaps use an HTTPRequest class object instead.
 

Users who are viewing this thread

Back
Top Bottom