So I've been trying to navigate to an already opened IE window using VBA. I've found a post explaining what seems to be how to do this. However, my main problem now is that I'm not too familiar with VBA and my website in particular, doesn't seem to have a document title. All I have in the html code when i inspect it in the Debugger is the following:
<title></title>
Am I missing something here? Is there any other way to refer to the website that may be easier or simpler?
Sub demo()
Dim str_val As Object
marker = 0
Set objShell = CreateObject("Shell.Application")
IE_count = objShell.Windows.Count
For x = 0 To (IE_count - 1)
On Error Resume Next
my_url = objShell.Windows(x).document.Location
my_title = objShell.Windows(x).document.Title
If my_title Like "XYZ" & "*" Then
Set IE = objShell.Windows(x)
marker = 1
Exit For
Else
End If
Next
If marker = 0 Then
MsgBox ("A matching webpage was NOT found")
Else
MsgBox ("A matching webpage was found")
Set str_val = IE.document.getElementById("txtbox1")
str_val.Value = "demo text"
End If
End Sub
Reference
VBA code to interact with specific IE window that is already open