I have been trying to automate something on my computer and sometimes I might require to disconnect my router, I have tried everything but it seems to be skipping part of my code, the part where it clicks the disconnect button >.<
Here is the code
Code:
Sub Restart_Router()
Dim StInputEle As MSHTML.htmlinputelement
Set objIE = CreateObject("InternetExplorer.Application") ' creating internet explorer object
With objIE
.Visible = True
.navigate "http://192.168.2.1/" ' going to router page
strt = Timer
Do While .Busy Or _
.Readystate <> 4 ' waiting for page to load
DoEvents
If Timer - strt > 10 Then Exit Do 'timer to prevent endless loop
Loop
.document.getElementsByName("pws").Item(0).Value = "password" 'entering the password
For Each StInputEle In .document.getElementsByTagName("input") ' searching for the login button
If StInputEle.Type = "submit" Then
StInputEle.Click ' clicking the button once it finds it
Exit For
End If
Next StInputEle
Do While .Busy Or _
.Readystate <> 4 ' waiting for page to load
DoEvents
If Timer - strt > 10 Then Exit Do 'timer to prevent endless loop
Loop
For Each StInputEle In .document.getElementsByTagName("input") 'here is where it skips the code, it skips the whole for each
If StInputEle.Type = "submit" Then
StInputEle.Click ' clicking the button once it finds it
Exit For
End If
Next StInputEle
End With
End Sub
Here is the HTML code snippet for the login button which the code works fine one
Code:
<td nowrap="">
<input type="Submit" value="LOGIN">
<input type="button" value="CANCEL" onclick="window.close();">
</td>
and here is the HTML code snippet for the disconnect button which will not click
Code:
<p><input type="submit" value="Disconnect" name="disconnect" onclick="return dhcp_release();"></p>
Please help!!