ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Interrupting initializing stage (https://www.excelbanter.com/excel-programming/355956-interrupting-initializing-stage.html)

Maxi[_2_]

Interrupting initializing stage
 
I have a software that I am opening through Excel VBA, it inputs the
username, password and IP address and logs in to that software.

If I supply correct password, the macro works, it opens the software,
supplies username, password and IP and logs in

but if I supply incorrect password, it goes in an endless loop.

When I open the software physically (without the macro) and supply
incorrect password, it gives me a box <<INITIALIZING and does not
come out of it for a very long time, I have to end task it to get rid
of it.

My question, can we tell excel vba programatically before the the
initializing line starts that if initializing takes more than 60
seconds, then inturrupt that stage and go forward.

I tried on error resume next but it does not work as it does not gives
any error.

Any ideas???

Code:

Sub try()

    Dim App As Object
    Dim Conn As Object
    Dim Srv As Object

    Set App = CreateObject("MySoftware.Application")
    Set Conn = CreateObject("MyConnection..Connection")
    Set Srv = CreateObject(""MyServer.Server")

    If App.CreateServer("username", "", "", "my IP Address", False,
"ENU", Srv, Conn) Then
        If Conn.Login("username", "password", "my IP Address", "ENU")
Then 'This is the initializing line
            MsgBox "Logged in"
        Else
            MsgBox "Unable to login"
        End If
    End If

Set App = Nothing
Set Conn = Nothing
Set Srv = Nothing
   
End Sub



All times are GMT +1. The time now is 12:10 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com