email wait 30 secs then login

Posted on 2006-04-24
Last Modified: 2010-05-18
I have this code in my VB6 form, but I dont want the (Do Until Not oIE.Busy)
I want to wait 30 secs then login.. how can I do that?

Dim oIE
On Error Resume next
'first get our login page
set oIE = CreateObject("InternetExplorer.Application")
oIE.Visible = True
oIE.Navigate ("")
Do Until Not oIE.Busy
'login to hotmail
oIE.Document.forms("f1").all("login").Value = ""
oIE.Document.forms("f1").all("passwd").Value = "mypassword"
Do Until Not oIE.Busy
Question by:aplelois
    1 Comment
    LVL 85

    Accepted Solution

    Something like...

    Click on Project --> References and check the "Microsoft Internet Controls" entry.
    Add a Timer control (Timer1).

    Option Explicit

    Private counter As Integer
    Private WithEvents IE As InternetExplorer

    Private Sub Form_Load()
        Timer1.Enabled = False
    End Sub

    Private Sub Command1_Click()
        If IE Is Nothing Then
            Set IE = CreateObject("InternetExplorer.Application")
            IE.Visible = True
        End If
        counter = 0
        IE.Navigate ""
    End Sub

    Private Sub IE_DocumentComplete(ByVal pDisp As Object, URL As Variant)
        counter = counter + 1
        Select Case counter
            Case 1
                ' login after 30 seconds...
                Timer1.Interval = 30000 ' 30 seconds
                Timer1.Enabled = True
            Case 2
                ' after something else in here...
        End Select
    End Sub

    Private Sub Timer1_Timer()
        Timer1.Enabled = False
        counter = counter + 1
        IE.Document.Forms("f1").All("login").Value = ""
        IE.Document.Forms("f1").All("passwd").Value = "mypassword"
    End Sub

    Private Sub IE_OnQuit()
        Set IE = Nothing
    End Sub

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now