Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Internet Explorer from Attachmate - wait command

Status
Not open for further replies.

blckngldhwk

Technical User
Feb 14, 2008
46
US
Code:
Sub Main()

	Dim System As Object, Sess As Object, MyScreen As Object
 
	Set System = CreateObject("EXTRA.System")

	Set Sess = System.ActiveSession

        Set MyScreen = Sess.Screen
        
        
        varA = MyScreen.getstring(40,11,03)
        
        varB = MyScreen.getstring(39,06,05)
        
        varC = MyScreen.getstring(39,11,04)
        
        
        Dim objIE As Object
               
        Set objIE = CreateObject("InternetExplorer.Application")


        objIE.Navigate "[internal address removed for privacy]"
        
        objIE.Visible = True 
   
        objIE.Document.All("txtvarA").Value = varA
        objIE.Document.All("txtvarB").Value = varB
        objIE.Document.All("txtvarC").Value = varC

        objIE.Document.All("btnsearchnow").Click

   
End Sub

The above code works great if I step through it but I am having a timing issue when I run it live. The issue is between the 'objIE.Visible = True' and 'VarA' lines of code. The code is trying step to the 'VarA' line when the page has not 'refreshed' yet so I get an error. It's only a split second that it's off but it's off. I have tried a 'while busy' command, 'waitfortimer' to no avail. How can I tell the code to wait until the page is loaded to move on?

Thanks!
 
This is what I use:

Code:
While objIE.Document.ReadyState <> "complete"
' Do Nothing
Wend

or:

Code:
While objIE.Busy
'Do Nothing
Wend
 
as the two previous posters indicated, generally anytime you step through code and it works but then will not execute with the 'run' command you are going to find a timing issue.

personally, I user count timers to delay the execution of some sections of code however, the document.readystate option seems to be the best idea here. let us know if you have been able to fix it or not
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top