hi all,
I’m trying to figure out how to have a macro bring up a website (an internal document website) locate the correct frame uncheck a box, fill in a field with a cell value (from A2) click submit, jump to the next frame within the same website and click a link. my main problem is it looks as though there are nested frames and iframes which im not familiar with. since the website is internal and you wont be able to access it, i have taken snips of the website itself, along with snips of the html and posted them to photobucket. http://s667.beta.photobucket.com/user/kboy1289/library/</SPAN></SPAN>
if you look at the snip of the website the fields i need to be referenced or filled are...
in the frame "frameSearchCriteria" (which i believe is itself within an iframe)
"My Loans Only" box unchecked (html name is "xMyContainers")
"Loan Number" field filled with cell A2 (html name is "xObjectSearchValue")
"Search" button clicked (html ID is "xSearchSubmit")
after these steps have been taken it would then jump to the next frame "frameSearchResults"
and would click the row (html name is "xRowClickAction")
i realize this would be difficult without access to the site, however the posted html and a snip of the website should help. heres two versions of code i have so far, any help is greatly appreciated! thanks!
I’m trying to figure out how to have a macro bring up a website (an internal document website) locate the correct frame uncheck a box, fill in a field with a cell value (from A2) click submit, jump to the next frame within the same website and click a link. my main problem is it looks as though there are nested frames and iframes which im not familiar with. since the website is internal and you wont be able to access it, i have taken snips of the website itself, along with snips of the html and posted them to photobucket. http://s667.beta.photobucket.com/user/kboy1289/library/</SPAN></SPAN>
if you look at the snip of the website the fields i need to be referenced or filled are...
in the frame "frameSearchCriteria" (which i believe is itself within an iframe)
"My Loans Only" box unchecked (html name is "xMyContainers")
"Loan Number" field filled with cell A2 (html name is "xObjectSearchValue")
"Search" button clicked (html ID is "xSearchSubmit")
after these steps have been taken it would then jump to the next frame "frameSearchResults"
and would click the row (html name is "xRowClickAction")
i realize this would be difficult without access to the site, however the posted html and a snip of the website should help. heres two versions of code i have so far, any help is greatly appreciated! thanks!
Code:
Public Sub IE_Automation()
Dim baseURL As String
Dim IE As InternetExplorer
Dim HTMLDoc As HTMLDocument
Dim mainFrame As HTMLIFrame
Dim slotsDiv As HTMLDivElement
Dim frmCol As FramesCollection
Dim htmlColl As Object
Dim htmlInput As Object
baseURL = "[URL]http://imaging/xsuite/xapps/default.aspx[/URL]"
Set IE = New InternetExplorer
With IE
.Visible = True
'Navigate to the main page
.Navigate baseURL & ""
While .Busy Or .readyState <> READYSTATE_COMPLETE: DoEvents: Wend
'Get the mainFrame iframe and navigate to it
Set mainFrame = .document.getElementById("xProjectFrame1_Panel")
.Navigate baseURL & mainFrame
While .Busy Or .readyState <> READYSTATE_COMPLETE: DoEvents: Wend
Set frmCol = IE.document.Frames 'Get the frame collection
Set HTMLDoc = frmCol.Item(1).document 'Get the HTML document within the frame
Set htmlColl = HTMLDoc.getElementsByName("xMyContainers") 'Get the input collection from this HTML doc
For Each htmlInput In htmlColl
If htmlInput.Name = "xMyContainers" Then htmlInput.Value = ("0")
Next htmlInput
Set htmlColl = HTMLDoc.getElementsByName("xObjectSearchValue") 'Get the input collection from this HTML doc
For Each htmlInput In htmlColl
If htmlInput.Name = "xObjectSearchValue" Then htmlInput.Value = ("4213010634")
Next htmlInput
Do While IE.Busy: DoEvents: Loop
Do While IE.readyState <> 4: DoEvents: Loop
Set IE = Nothing
End With
End Sub
Code:
Sub Xdoc()
Dim oIE As InternetExplorer
Dim HTMLDoc As HTMLDocument
Dim frmCol As FramesCollection
Dim HTMLFrame As HTMLDocument
Dim htmlColl As Object
Dim htmlInput As Object
Set oIE = CreateObject("InternetExplorer.Application")
oIE.Navigate ("[URL]http://imaging/xsuite/xapps/default.aspx[/URL]")
Do While oIE.Busy: DoEvents: Loop
Do While oIE.readyState <> 4: DoEvents: Loop
oIE.Visible = True
' Go through <FRAME>to get to main document
Set frmCol = oIE.document.Frames 'Get the frame collection
Set HTMLFrame = frmCol.Item(2).document 'Get the HTML document within the frame
Set htmlColl = HTMLDoc.getElementsByName("xMyContainers") 'Get the input collection from this HTML doc
For Each htmlInput In htmlColl
If htmlInput.Name = "xMyContainers" Then htmlInput.Value = ("0")
Next htmlInput
Set htmlColl = HTMLDoc.getElementsByName("xObjectSearchValue") 'Get the input collection from this HTML doc
For Each htmlInput In htmlColl
If htmlInput.Name = "xObjectSearchValue" Then htmlInput.Value = ("4213010634")
Next htmlInput
Set htmlColl = HTMLDoc.getElementsByName("Search") 'Get the input collection from this HTML doc
For Each htmlInput In htmlColl
If htmlInput.Name = "Search" Then htmlInput.Click
Next htmlInput
Do While oIE.Busy: DoEvents: Loop
Do While oIE.readyState <> 4: DoEvents: Loop
Set oIE = Nothing
End Sub