Form.Submit does not go through when using VBA

后端 未结 1 699
执笔经年
执笔经年 2021-01-13 07:58

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

相关标签:
1条回答
  • 2021-01-13 08:54

    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
    
    0 讨论(0)
提交回复
热议问题