Link to home
Start Free TrialLog in
Avatar of a6106a
a6106a

asked on

How do I make the current URL appear in the titlebar

My app uses the IE Browser control to display websites. I need the current URL to appear in the title bar of the form. How can I do this?
Avatar of ture
ture

Something like this?

Private Sub WebBrowser1_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
  Me.Caption = URL
End Sub

Ture Magnusson
Karlstad, Sweden
go does this:

frmMain.caption = "My Web Browser is located at - " & WebBrowserControl.URL

Thats should work - i have personally never used to control so i dont know what your control is called - Replace 'WebBrowserControl' with the controls name and that should work.
Avatar of a6106a

ASKER

Lexien: The Web Browser Object (the Globe) doesn't have the URL property:
Tuer: Please tell me how to insert your code. I'm not too proficient. I've tried it several places but can't make it work.
a6106a,

This shoulddn't be that difficult...

1. Show the form that contains your web browser object.
2. Double-click the web-browser object on the form.

(You will see the form's code window.)

3. Above the code window are two listboxes. In the second listbox, choose 'NavigateComplete2'.

Now enter this code inside the xxxxx_NavigateComplete2 procedure:

Me.Caption = URL

/Ture
Okay I will post two different Solutions.

1)Getting the Name of the web site on the title bar.

Create a: Form, WebBrowser Control

Size the form to the size you want, next draw the WebBrowser control to the size you want. Next double click on the form and past this code.

Private Sub Form_Load()
WebBrowser1.Navigate "http://www.msn.com"
End Sub

Private Sub WebBrowser1_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
Form1.Caption = WebBrowser1.LocationName
End Sub

This will open the MSN web site in your browser control, and display the Web Pages title as your Forms Caption.

2)Getting the Address of the web site on the title bar.

Create a: Form, WebBrowser Control

Size the form to the size you want, next draw the WebBrowser control to the size you want. Next double click on the form and past this code.

Private Sub Form_Load()
WebBrowser1.Navigate "http://www.msn.com"
End Sub

Private Sub WebBrowser1_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
Form1.Caption = WebBrowser1.LocationURL
End Sub

This will open the MSN web site in your browser control, and display the Web Pages address on your Forms Caption.


k, sorry - like i said i've never used the WebBrowser control before.

merry xmas

;)
Avatar of a6106a

ASKER

mazur: please answer. yours worked fine for me.
thank you to all for your help.
a6106a,

Didn't my suggestion work? Or perhaps I diddn't explain myself clearly enough?

/Ture
ASKER CERTIFIED SOLUTION
Avatar of Mazer
Mazer

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of a6106a

ASKER

I'm sorry I can't give points to everyone who helped here. Thanks again to you.