Question

The company I work for uses LinkedIn as a data source to populate our database with contacts. Currently the process is manual, and I would like to automate part of this process.

I am trying to write a script in VBScript or VBA that will parse through the contents of an already open webpage. I want the script to evaluate the description sections of each person on LinkedIn and based on specific criteria place the person's name, description, and LinkedIn link in Excel. I have already done some VBScript scripting where I can open a webpage and read through the HTML contents, but I would like to utilize an already open webpage to make use of LinkedIn's filtering features.

Was it helpful?

Solution

Here's a function you can use to get a reference to an already-open IE window (given a URL to match on)

'usage:
Dim IE
Set IE = GetIE("http://www.linkedin.com")
If Not IE Is Nothing Then
    'work with IE object
End If




'Find an IE window with a matching (partial) URL
'Assumes no frames.
Function GetIE(sAddress As String) As Object

Dim objShell As Object, objShellWindows As Object, o As Object
Dim retVal As Object, sURL As String


    Set retVal = Nothing
    Set objShell = CreateObject("Shell.Application")
    Set objShellWindows = objShell.Windows

    'see if IE is already open
    For Each o In objShellWindows
        sURL = ""
        On Error Resume Next
        sURL = o.document.Location
        On Error GoTo 0
        If sURL <> "" Then
            If sURL Like sAddress & "*" Then
              Set retVal = o
              Exit For
            End If
        End If
    Next o

Set GetIE = retVal
End Function
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top