Skip to content Skip to sidebar Skip to footer

Form.submit Does Not Go Through When Using Vba

I have a webpage that I am extracting data from. I can do everything fine with VBA apart from clicking on an image element which then submits a form and a popup with data is create

Solution 1:

Give this a shot, I doubt this is going to be the 'perfect' answer without actually seeing the site. However, this should find the correct image tag, assuming you don't have any frames/iframes (please check there aren't any), and should click it.

Public Sub Click_IMG_Tag()
    Dim Elements As Object
    Dim Element  As Object

    'Get a pointer to IE etc first, I'm assuming this is already done

    Set Elements = IE.Document.getElementsByTagName("img")

    For Each Element In Elements
        On Error Resume Next ' used to bypass elements that don't have .Title property
                             ' later, you should error handle this exception
        If Element.Title = "View Quantities At Other Locations" Then
            Element.Focus
            Element.Click
            Element.FireEvent ("OnClick")
            IELoad IE
            Exit For
        End If
    Next

End Sub

Public Sub IELoad(Browser As Object)
    While Browser.busy Or Browser.Readystate <> 4
        Application.Wait (Now() + TimeValue("00:00:01"))
        DoEvents
    Wend
End Sub

Post a Comment for "Form.submit Does Not Go Through When Using Vba"