Reflection Desktop VBA Guide
Attachmate.Reflection.Objects Library / Attachmate.Reflection.Objects.Web.Msie Library / WebDocument Object / GetElementById Method
Element Id.
Example
In This Topic
    GetElementById Method
    In This Topic
    Gets a Web element by ID.
    Syntax
    expression.GetElementById( _
       ByVal Id As String _
    ) As WebElement object 
    where expression is a variable that represents a WebDocument Object

    Parameters

    Id
    Element Id.

    Return Value

    A WebElement object
    Example
    This example navigates to a Web page and clicks on a link in the page. To run this sample, create and open a Web session and run this code in the session code module.
    Sub webClick()
        
        'Declare variables:
     
        Dim wControl As Attachmate_Reflection_Objects.WebControl
        Dim wDocument As WebDocument
        Dim wElement As WebElement
        Dim wElementInput As WebElement
         
     
        Set wControl = ThisWebControl
        
        'Get a handle to the workspace
        Set app = GetObject("Reflection Workspace")
     
        'Go to the Host Access Analyzer documentation page
        wControl.Navigate1 ("https://www.microfocus.com/documentation/host-access-analyzer/")
                
        'Wait until the Web page is ready and then set it as the Web document
        Do Until wControl.ReadyState = WebBrowserReadyState_Complete
          app.Wait (1000)
        Loop
        
        Set wDocument = wControl.Document
        
        'Get the table that includes the link
        Set wElement = wDocument.GetElementById("getting_started")
        
        'Get the link element
        Set wElementInput = wElement.GetElement("tbody/tr[0]/td[0]/a[0]")
     
        
        'Click the link
        wElementInput.Click
        
        'Print the tag name of the element
        Debug.Print wElementInput.tagName
        
    End Sub
    See Also