Use reference to Internet Explorer Controls..and pass the window name you want to wait in IEpg.
Put this code in Shared Modules and place a call to function when ever required.
Public Function IESync()
Dim IE As New InternetExplorer, MyIE As New InternetExplorer
Dim wShell As New ShellWindows
Dim sAccType As String, IEpg As String, Elaps_Time As Integer
For Each MyIE In wShell
If MyIE.LocationURL Like "*" & IEpg & "*" Then
Set IE = MyIE
Elaps_Time = 0
Elaps_Time = Elaps_Time + 1
Sleep 1, tpPauseSeconds
Loop Until IE.Busy = False And Elaps_Time < IE_Sync_Time
You can also loop for checking if HTMLBrowser("Caption='*'") exists. I've noticed that sometimes IE.Busy is false, but HTMLBrowser can't be found because the page is still being rendered.
Alias' suggestion works as well, but I don't like increasing attach time out, since that means that if the attach name is really not found (due to an error) you have to wait long time for test to fail.
1) Attach Time Out is the easiest way to control this. It allows you to not have to code anything extra into your script and control it globaly. You can also change this value programatically in the script using playback.attachtimeout = x
2) If you have points in your script where you may experience EXTRA long delays, this is a good point to use a WAIT event or the HTMLBrowser("Object",tpAttachNoWait).exists loop.
3) Using IE.Busy is a good approach, it just requires a lot of work that the tool can/should handle with the sycronization already built in.
I find that there is nothing wrong with good old fashion SLEEPs from time to time. Nothing crazy but if I know a page is a little slower than others I will through a sleep 2 or sleep 5 before the attach. Screens will hardley ever load faster than 2 seconds so I am only loosing a few seconds in exe time, but it makes the script run cleaner because when TP is "sleeping" its not using any CPU processing time, and letting the application under test have it all.