Search code examples
javavbainternet-explorerautomationinvisible

Control an Element in invisible Internet Explorer vba


is there a way that i can control an invisible IE with this Element. When IE is visible i can use focus and Sendkey functions. But don't know how, when it is invisible

<tr bgcolor="#c8d8f8">
<td valign=top colspan=2>
<b>Link_Nr / Link_St</b>
<br>
<input type="text" name="LINK" id="link" size="70" value="" 
onKeyUp="Auswahl_Link();">
</td>
</tr>

My way till now:

IEDocument.all.LINK.Value = linknummer
IEDocument.all.Item("Link").Focus ("Link")

If IEDocument.all.Item("Link").SetFocus Then
    Application.SendKeys "{UP}", True
End If

Solution

  • You are using SendKeys to trigger the event when potentially you can trigger the event as shown below.

    IEDocument.querySelector("#zeichn").fireEvent "onKeyUp"
    

    or

    IEDocument.getElementById("zeichn").fireEvent "onKeyUp"
    

    I have never tried setting focus when IE.Visible = False but, if it is possible, then you may need to .Focus, on the element, before doing the above.