Home > Software engineering >  IE object operation failure problem... Walk pass by, come all, thank you
IE object operation failure problem... Walk pass by, come all, thank you

Time:09-16

Recently doing a function, is to use excel spreadsheets online via IE object implementation conversion function of GPS coordinates, the following code
Private Sub test ()
Dim STR, t, t1, s1, s, l As String
Dim d, g, q, I As Long
Dim nowtime, clicktime, retime the As Single
Dim ie As Object
I=0
Set the ie=CreateObject (" InternetExplorer. Application ")
Ie. Navigate website "https://tool.lu/coordinate/" 'visit
Ie. Visible=True 'on the display page
Nowtime=Timer
Do Until ie. ReadyState=4 And ie. Busy=False 'if ie loaded
DoEvents' when the form loads transfer operation rights
If Abs (Timer - nowtime) & gt; 10 Then=
Ie. Qiut
MsgBox "timeout"
Sheet1. Application. StatusBar=""
The Exit Sub
End the If
Loop
With ie
. The document. The getelementbyid (" wgs84 "). The innertext=""
. The document. The getelementbyid (" src_coordinate "). The Value=https://bbs.csdn.net/topics/Trim (Sheet1. Range (" C1 "))
. Document. All tags (" input ") (2) Checked="1"
. Document. All. Tags (" button ") (1). Click
Clicktime=control loop interval Timer '
Do Until the ReadyState=4 And. Busy=False And Timer & gt; Clicktime + 0.3 'if IE loaded
DoEvents' when the form loads transfer operation rights
If Abs (Timer - clicktime) & gt; 10 Then=
Ie. Quit
The Set ie=Nothing
MsgBox "timeout"
Sheet1. Application. StatusBar=""
The Exit Sub
End the If
Loop
End With
End the If
End Sub
The detailed status code debugging without a little problem, but there is a direct run continuously, the site is opened, I can see the box from the initial coordinate system jumped to the second, third. Document. All the tags (" input ") (2) Checked="1" on success, but less than 0.1 seconds automatically jump to the third and then click quickly,,,, so I found out the coordinates of the wrong,,, how to settle this problem?
But the strange thing is if I use cycle batch query multiple data tend to be the first one or two data will have a problem, to would be all right again, back, and now my solution simple and crude, is in the first of the DO loop and timer> Clicktime + 2, was no problem, but I feel this way too passive and inconvenient,,,
Everyone a great god have a better solution?

CodePudding user response:

On baidu again, I now feel is probably the iframe, could have triggered by record DocumentComplete to judge whether the number of times to load, but why do I use IE objects cannot be directly triggered? Be sure to use wb controls?
  •  Tags:  
  • VBA
  • Related