1
votes

I am accessing website which is very complicated so that Msxml2.XMLHTTP is not working. I tried followint Ie Automation.

'Working
with createobject("internetexplorer.application")
  .navigate url
  Do While .ReadyState = 4: WScript.Sleep 1000: Loop
  Do While .ReadyState <> 4: WScript.Sleep 1000: Loop
  .document.body.createtextrange.select
  .document.execCommand "copy"
  strURL = .document.parentwindow.clipboardData.GetData("text")         
  .quit
end with
MsgBox strURL

But this every time load the full content as unanswered in Failproof Wait for IE to load

If I want to load the webpage until instr(strURL, "some text") is true, is there any way?

I don't understand why .ReadyState = 4 doesn't load the page. is it due to javascript might not be ready?

I added one more sleep like this.

If Not instr(strtxt, "some Text") > 0 then
        WScript.Sleep 10000
    .document.body.createtextrange.select
    .document.execCommand "copy"
  strtxt = .document.parentwindow.clipboardData.GetData("text")

This gives result most of the time in my environment but I don't get any Idea how to check untill the required text is loaded.

1

1 Answers

0
votes

This is an Idea.

keepSleeping = false 'is my requirement
keepSleeping=instr(.document.body.innerhtml, "sometext") <> 0
while keepSleeping
   WScript.Sleep 20
   keepSleeping=instr(.document.body.innerhtml, "sometext")
wend