The Amsterdam Excel Summit

Results 1 to 3 of 3

Thread: Hyperlink - Using SAME Browser Window

  1. #1
    Site Admin
    The Princess
    VBAX Guru Anne Troy's Avatar
    May 2004
    Allentown, Pennsylvania

    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.
    ~Anne Troy

  2. #2
    VBAX Regular
    May 2004
    Driffield, East Yorkshire, Egnland
    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!



  3. #3
    Quote Originally Posted by Dreamboat

    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 ""
    	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"
    	End With
    	Do While .busy: DoEvents: Loop
    	Do While .ReadyState <> 4: DoEvents: Loop
    	Do While Not CBool(InStrB(1, .Document.URL, _
    	.Visible = True
    	Call ShowWindow(.hwnd, 3)
    End With
    Set ie = Nothing
    Exit Sub
    1: MsgBox Err.Description
    	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.
    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