Hi,

I am trying to get some information about Yammer groups. Using the video tutorial in the link below I have modified the code to get the number of members from a yammer groups page. I am getting the error message "Run time error '91': Object variable or With block variable not set". If I then click debug, and carry on running the program it works fine as if there was never an error. It also works if I put a breakpoint on the line "sMembers = Trim(Doc.getElementsByClassName("yj-count")(1).innerText)" and then step past it, it jsut wont run all in one go. Despite searching the problem I have no idea what the problem could be.

http://www.youtube.com/watch?v=7sZRcaaAVbg

The code I am using is:

Private Sub Worksheet_Change(ByVal Target As Range)
    ' Variable declerations
    Dim sMembers As String
    Dim Doc As HTMLDocument
    Dim IE As New InternetExplorer
    
    ' Getting the group ID from the excel sheet
    If Target.Row = Range("GroupID").Row And _
    Target.Column = Range("GroupID").Column Then
        
        ' Show the web page (not needed)
        IE.Visible = True
        ' Navigate to the web page
        IE.navigate "https://www.yammer.com/centrica.com/#/threads/inGroup?type=in_group&feedId=" & Range("GroupID").Value
        ' Stop the screen freexing while it's processing
        Do
            DoEvents
        Loop Until IE.readyState = READYSTATE_COMPLETE

        Set Doc = IE.document
        
        'Finding the information on the page
        sMembers = Trim(Doc.getElementsByClassName("yj-count")(1).innerText)
        IE.Quit
        Range("Members").Value = sMembers
        
        
    End If
End Sub
Thanks in advance for your help,

Regards,

Geraint