Consulting

Results 1 to 3 of 3

Thread: Sleeper: Hyperlink - Using SAME Browser Window

  1. #1
    Site Admin
    The Princess
    VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location

    Sleeper: Hyperlink - Using SAME Browser Window

    Interesting question from elsewhere:

    I have a local spreadsheet file in Excel 2003. I add values to a cell and hyperlink to a website. How can I have that open up the hyperlink in an _existing_ Internet Explorer instance? It always launches a new instance on me. I need it to be an existing instance because all my hyperlinks are on pages that require authentication.
    Anybody?
    ~Anne Troy

  2. #2
    VBAX Regular
    Joined
    May 2004
    Location
    Driffield, East Yorkshire, Egnland
    Posts
    69
    Location
    Hmmm. I've read somewhere recently about forcing IE to use the same window using VBA - maybe this could be used in this instance. Trouble is with the hyperlinks on the sheet, they will probably need to be removed.

    Anne, you said the question was from elsewhere, could I ask which one, as I think I can come up with some kind of solution but need a bit more info first!

    Cheers,

    Ad

  3. #3
    VBAX Regular NateO's Avatar
    Joined
    Jun 2004
    Location
    Minneapolis, MN
    Posts
    90
    Location
    Quote Originally Posted by Dreamboat
    Anybody?
    Hello,

    I thought I had answered this at some point, but I can't find it...

    Well, I never really have liked hyperlinks, but I do like VB. So, you want to control a secure website in an instance of an Internet Explorer App? You can do so with a new instance, you never need to see it actually. Below is an example of logging into this website, and shows how to pass values and submit them to the site. Simply change your Username and Password:

    Public Declare Function ShowWindow& Lib "user32" ( _
    ByVal hwnd As Long, ByVal nCmdShow As Long)
     
    Private Sub Yadda()
    Dim ie As Object
    Set ie = CreateObject("InternetExplorer.Application")
    On Error GoTo 1
    With ie
        .navigate "http://www.vbaexpress.com/forum/index.php"
        Do While .busy: DoEvents: Loop
        Do While .ReadyState <> 4: DoEvents: Loop
        With .Document.Forms(1)
            .vb_login_username.Value = "UserName"
            .vb_login_password.Value = "Password"
            .submit
        End With
        Do While .busy: DoEvents: Loop
        Do While .ReadyState <> 4: DoEvents: Loop
        Do While Not CBool(InStrB(1, .Document.URL, _
            "index.php"))
            DoEvents
        Loop
        .Visible = True
        Call ShowWindow(.hwnd, 3)
    End With
    Set ie = Nothing
    Exit Sub
    1: MsgBox Err.Description
    ie.Quit
    Set ie = Nothing
    End Sub
    From here you can scrape a screen, etc... Sorry about the delayed response.

    Edit: I switched to the code tags, the spacing didn't look right to me with the VBA tags, still doesn't look right, appears to have extra tabs (I.E. 6.0), but it copies and pastes fine.
    Regards,
    Nate Oliver

Posting Permissions

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