• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Switch to web iframe and fill drop-downs using excel vba

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:
Code:
<frame name="displayFrame" src="/webpr/webpr.php?objtype=MyWebPR&amp;g_userid=a3rgcw&amp;g_session_id=7321635&amp;g_devmode=&amp;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"
 
Back
Top