PDA

View Full Version : .Click in IE only works every few attempts



b.hill
10-07-2016, 07:12 PM
Hello, I am trying to go to a site and play a soundbite. I am having trouble getting the soundbite to play every time with my code. It will play every few times though which is the strange thing to me. Also when I run the code I get a "Run-Time Error 91: Object Variable or With Block Variable not set" on the oBrowser.document.getElementsByClassName("play")(0).Click line, but when I step through the code I do not get the error. Any ideas on how to fix this and get the soundbite to play every time? Thank you.



Sub Encore()


Dim sURL As String


sURL = "http://forvo.com"


Set oBrowser = New InternetExplorer
oBrowser.Silent = True
oBrowser.navigate sURL
oBrowser.Visible = True


Do While oBrowser.Busy: DoEvents: Loop


oBrowser.navigate "http://forvo.com/search/encore/fr"
Do While oBrowser.Busy: DoEvents: Loop
oBrowser.document.getElementsByClassName("play")(0).Click


Application.Wait Now + TimeValue("00:00:03")


Beep

End Sub