PDA

View Full Version : Sleeper: Hyperlink - Using SAME Browser Window



Anne Troy
07-01-2004, 07:50 PM
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?

Adaytay
07-02-2004, 12:36 AM
Hmmm. I've read somewhere recently about forcing IE to use the same window using VBA - maybe this could be used in this instance. :confused: Trouble is with the hyperlinks on the sheet, they will probably need to be removed. :dunno

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

NateO
11-30-2004, 01:32 PM
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.