+ Reply to Thread
Results 1 to 7 of 7

Macro timing might be the problem

  1. #1
    Registered User
    Join Date
    05-06-2004
    Posts
    60

    Macro timing might be the problem

    Hello,

    My current macro is unreliable for some reason. Depending on the value of certain cells in Sheets("SONET"), I would like to open a new browser for the web address in each cell in a specific range. The following code is working, but not always....not sure why. I am trying to slow down the macro to allow the user the ability to enter their user name and password into a pop up box before the next browser is opened. Is there a way to recognize not to open other browers until after the user name and password are entered ?

    Thank you


    Private Sub CommandButton2_Click()

    Dim ws3 As Worksheet
    Set ws3 = Worksheets("SONET")

    Dim sPath As String

    Dim sURL As String
    Dim tURL As String
    Dim uURL As String
    Dim vURL As String
    Dim wURL As String
    Dim xURL As String

    Dim dTaskID As Double
    Dim eTaskID As Double
    Dim fTaskID As Double
    Dim gTaskID As Double
    Dim hTaskID As Double
    Dim iTaskID As Double

    sPath = "C:\Program Files\Netscape\Communicator\Program\netscape.exe" 'my browser

    With Application
    Sleep 7000

    If ws3.Range("B2").Value = "0" Then
    MsgBox "No systems to check"
    End If

    If ws3.Range("B2").Value > "0" Then
    sURL = Sheets("SONET").Range("J2").Value
    dTaskID = Shell(sPath & " " & sURL, vbNormalFocus)

    Sleep 500
    End If
    If ws3.Range("B3").Value > "0" Then
    tURL = Sheets("SONET").Range("J3").Value
    eTaskID = Shell(sPath & " " & tURL, vbNormalFocus)

    Sleep 500
    End If
    If ws3.Range("B4").Value > "0" Then
    uURL = Sheets("SONET").Range("J4").Value
    fTaskID = Shell(sPath & " " & uURL, vbNormalFocus)

    Sleep 500
    End If
    If ws3.Range("B5").Value > "0" Then
    vURL = Sheets("SONET").Range("J5").Value
    gTaskID = Shell(sPath & " " & vURL, vbNormalFocus)

    Sleep 500
    End If
    If ws3.Range("B6").Value > "0" Then
    wURL = Sheets("SONET").Range("J6").Value
    hTaskID = Shell(sPath & " " & wURL, vbNormalFocus)

    Sleep 500
    End If
    If ws3.Range("B7").Value > "0" Then
    xURL = Sheets("SONET").Range("J7").Value
    iTaskID = Shell(sPath & " " & xURL, vbNormalFocus)
    End If

    End With
    End Sub


    Thanks

    Oreg

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Oreg,

    Are you generating the password popup or is the browser?

    Thanks,
    Leith Ross

  3. #3
    Registered User
    Join Date
    05-06-2004
    Posts
    60

    Macro timing might be the problem

    Hi Leith,

    The website is generating the password popup. I've tried sending the user name and password inserted into the URL address but that doesn't seem to work. Sendkeys is not reliable. What I've found is once the username and password is entered, all other browsers no longer require the password to be entered. I was attempting to allow the user time to enter the username and password in before the next browser appears. If the other browsers open before the password is entered, they do not load.

    Oreg

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Oreg,

    Tell me the sequence of events. Does the user select the browser first and then it launchs and the popup is displayed or something different?

    Thanks,
    Leith

  5. #5
    Registered User
    Join Date
    05-06-2004
    Posts
    60

    RE: Macro timing might be the problem

    Hi Leith,

    My userform has a listbox which displays a list of systems (data located in Sheets("SONET"). In column J of Sheets("SONET") is a URL address for each system. Basically, the only difference between each system's URL address is an ID number on the back end of the URL. When a button is pressed on my form, the URL in cells J2 should be loaded first. The Website is password protected, so I was trying to use Sleep to allow time for the user to enter their usrname and password. After the password is entered one time, all other systems( for cells (J3, J4 ....) and so on, would open in seperate browsers.

    Thanks,

    Oreg

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Oreg,

    Do you know of any other way to trigger a password request other than passing a URL to the server?

    Leith

  7. #7
    Registered User
    Join Date
    05-06-2004
    Posts
    60

    Macro timing might be the problem

    Leith,

    I don't know of another way to trigger the password request other than passing the URL....unfortunately.

    Oreg

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1