InfoConnect VBA Guide
Attachmate.Reflection.Objects.Web.Msie Library / WebDocument Object / Extract Method
Example
In This Topic
    Extract Method (WebDocument)
    In This Topic
    Extracts text delimited by pretext and posttext from an HTML text source.
    Syntax
    expression.Extract( _
       ByVal pretext As String, _
       ByVal posttext As String, _
       ByVal singleLine As Boolean _
    ) As String()
    where expression is a variable that represents a WebDocument Object

    Parameters

    pretext
    posttext
    singleLine
    Example
    This sample extracts text from a Web page and prints the text.
    'This sample gets text on a Web page
    Sub extract()
     
        Dim app As Attachmate_Reflection_Objects_Framework.ApplicationObject
        Dim text() As String
        Dim webText As String
        Dim size, i As Integer
        
        'Get a handle to the workspace
        Set app = GetObject("InfoConnect Workspace")
     
        'Go to a Web page
        ThisWebControl.Navigate1 "https://www.microfocus.com/documentation/reflection-desktop/17-0/vba-guide/AboutVBA.html"
     
        'Wait until the document is ready
        Do Until ThisWebControl.ReadyState = WebBrowserReadyState_Complete
          app.Wait (1000)
        Loop
        
        'Get the text on the first paragraph
        text = ThisWebControl.Document.extract("Visual Basic for Applications", "objects", False)
        
        'Get the size of the array that is returned
        size = UBound(text) - LBound(text) + 1
     
        'If text is returned, print the text
        If size = 0 Then
            Debug.Print "Did not find text"
        Else
            For i = 0 To UBound(text)
                Debug.Print text(i)
            Next
        End If
        
    End Sub
    See Also