Access/VBA Library

getElement Method

Returns the first element on the current webpage matching the given CSS-selector.

See also: https://www.w3schools.com/cssref/css_selectors.asp

Syntax

clsIE.getElement( cssSelector )
Parameters
Name Type Description
clsIE   The name of an object of type clsIE
cssSelector String Required. Pattern to select an element on the current webpage.
Return value

IHTMLElement : The element selected. When not found an Nothing is returned.

clsIEtag:clsIE
Example
Dim IE As New clsIE
Dim Element as IHTMLElement
IE.location = "https://www.w3schools.com"
' Get the element "Learn HTML" in the side navigation
Set Element = IE.getElement("#mySidenav a.w3-bar-item")
If Not (Element Is Nothing) Then
    ' Click the element selected
    Element.click
End if