rwhitmore90
New Member
- Joined
- Mar 6, 2014
- Messages
- 4
I have a few questions regarding internet explorer automation. I am using Excel 2010. I am trying to automate an internal web application. Unfortunately the web application from what I can tell is a series of java script functions. I would post the source code but for obvious reasons I am not allowed. Once you log in the URL never changes. I have set up my macro to look for the already open window. Once it does I want it to fill in a form. The macro for selecting the appropriate window works. The form is located in a table which is in an iframe. How can I input values into the form?
I have been messing around with the code a lot. I have tested whether it is finding the frame and it is. After that, I don't know how to work within the form that is located in a table. Any help would be greatly appreciated. Thank you!
Code:
Option Explicit
' Arguments:
' Title - title of the searchied IE window
' [IsLike] - False/True = exact/partial searching, default is False
' [IsFocus] - False/True = don't_activate/activate IE window, default is False
Function GetIeByTitle(Title, Optional IsLike As Boolean, Optional IsFocus As Boolean) As Object
Dim w As Object
For Each w In CreateObject("Shell.Application").Windows
With w
If .Name = "Windows Internet Explorer" Then
If IsLike Then
If InStr(1, .LocationName, Title, vbTextCompare) > 0 Then
If IsFocus Then
w.Visible = False
w.Visible = True
End If
Set GetIeByTitle = w
Exit For
End If
Else
If StrComp(.LocationName & " - " & .Name, Title, 1) = 0 Then
If IsFocus Then
w.Visible = False
w.Visible = True
End If
Set GetIeByTitle = w
Exit For
End If
End If
End If
End With
Next
Set w = Nothing
End Function
Sub Test_GetIeByTitle()
Dim IE As InternetExplorer
Dim Title As String
Dim frm As Variant
Dim frame As Variant
Title = "Withheld"
Set IE = GetIeByTitle(Title, True, True)
If IE Is Nothing Then
MsgBox "IE window with this Title is not found:" & vbLf & """" & Title & """", 48
Else
Set frame = IE.Document.getElementById("contentFrame")
Set frm = frame.Document.getElementById("frm1")
If inputForm Is Nothing Then
MsgBox "No form"
End If
End If
End Sub
I have been messing around with the code a lot. I have tested whether it is finding the frame and it is. After that, I don't know how to work within the form that is located in a table. Any help would be greatly appreciated. Thank you!