Calling a function help


New member
Sep 20, 2013
Reaction score
Hello, I'm not a VBA expert by any means. I found some code doing a google search that I would like to tailor to suit my needs. I want to search through already opened IE windows on my desktop and find the one I need, then copy all information from that IE window and paste the contents back into Excel. I'm stuck on how to call the function to search for an opened IE window that contains the title "ADMS". Thanks

'finds an open IE site by checking the title
Private Function GetOpenIEByTitle(i_Title As String, _
Optional ByVal i_ExactMatch As Boolean = True) As SHDocVw.InternetExplorer
Dim objShellWindows As New SHDocVw.ShellWindows

If i_ExactMatch = False Then i_Title = "*" & i_Title & "*"
'ignore errors when accessing the document property
On Error Resume Next
'loop over all Shell-Windows
For Each GetOpenIEByTitle In objShellWindows
'if the document is of type HTMLDocument, it is an IE window
If TypeName(GetOpenIEByTitle.document) = "HTMLDocument" Then
'check the title
If GetOpenIEByTitle.document.Title Like i_Title Then
'leave, we found the right window
Exit Function
End If
End If
End Function

Public Sub aSubprocedure()
' Any variables and other instructions go here
'How do I call the function here?
' Your code goes on
End Sub