Internet Explorer Automation with VBA input events

前端 未结 2 714
旧时难觅i
旧时难觅i 2020-12-09 23:12

am trying to use automation in from Microsoft Access 2003 to control Internet Explorer 9 to complete a form using database data.

The input fires an event in the br

相关标签:
2条回答
  • 2020-12-10 00:03

    If you want (in IE9) to put the following line right before line "Next i". it should also work even if you do not loose the focus?

    objRows(n).Cells(i).GetElementsByTagName("input")(0).Click

    0 讨论(0)
  • 2020-12-10 00:08

    After sweating over this for a few days, the answer was actually very simple but nearly impossible to find in any documentation on MSDN or anywhere else on the web.

    Before you change the value of the input field, you net to set the focus on that field. After you change the value, you need to set the focus to another field. Apparently, the events fire on the loss of focus. Therefore, the code should look like this:

            n = 0
        While n < objRows.Length
            If Trim(objRows(n).Cells(0).innertext) = "Family Room" Then
                For i = 1 To 7
                    objRows(n).Cells(i).GetElementsByTagName("input")(0).Focus
                    objRows(n).Cells(i).GetElementsByTagName("input")(0).Value = Format(RstAvailability!roomcount - RstAvailability!RoomsSold, "0")
                Next i
                objRows(n).Cells(1).GetElementsByTagName("input")(0).Focus
    
            End If
            n = n + 1
        Wend
    

    The way I found this was by looking at some MSDN documentation about accessibility for IE9. It was advising on setting the focus for disabled users. I just thought I would give this a try and it worked. I hope this helps someone else.

    Dave

    0 讨论(0)
提交回复
热议问题