Samadhan Gaikwad
Member
I have below code which opens web page, calls java-script function. What next I want is: Switch to iframe named displayFrame. Then select options in drop-downs. Currently I am unable switch to iframe and add values in form. I am new to this, so need your help.
Iframe code:
Iframe code:
Code:
<frame name="displayFrame" src="/webpr/webpr.php?objtype=MyWebPR&g_userid=a3rgcw&g_session_id=7321635&g_devmode=&g_dbname=">
Code:
Option Explicit
Sub Fillform()
Dim URL As String
Dim ie, frm As Object
Dim FF As Integer
Dim wb As WebBrowser
Dim objElement As Object
Dim objCollection As Object
Dim button, goBtn As Object
Dim HTML As HTMLDocument
Dim Dropdown As IHTMLElement
Dim dropOption As IHTMLElement
Dim HTMLdoc As HTMLDocument
Dim link As HTMLLinkElement
Dim theFrame As HTMLIFrame
Dim Frame1, Frame2 As HTMLIFrame
On Error Resume Next
Application.ScreenUpdating = False
URL = "https://webtac.industrysoftware.automation.siemens.com/webpr/webpr.php?objtype=frames&g_userid=a3rgcw&g_session_id=7302840" 'for TEST
Set ie = CreateObject("Internetexplorer.Application")
ie.Visible = True
ie.Navigate URL
Do Until ie.ReadyState = 4
DoEvents
Loop
' Call java-script function
ie.Navigate ("javascript:parent.gotoCreate('advanced');")
Do Until ie.ReadyState = 4
DoEvents
Loop
Set theFrame = HTMLdoc.frames(0)
Set HTML = ie.Document
ie.Document.all.Item("product_application").Value = "NX"
ie.Document.getElementById("textInputField").Value = "N/A"
Set Dropdown = HTML.getElementById("product_application")
For Each dropOption In Dropdown.getElementsByTagName("option")
If dropOption.innerText = "Design" Then
Dropdown.Value = dropOption.Value
Exit For
End If
Next dropOption
' or may be this way to select drop-down
ie.Document.getElementById("priority_selection").Value = "Design"