Loading a web page on a web browser control

A

Aaron

Hi guys,

In a workbook, I have a form where I have put in a web browser control.

I would like to be able to click on a command button to open the form and
populate the web browser control with a path on my computer eg.C:\Samples
folder.

I dont know how to get even a web address to be seen in the web browser
control.

Any help greatly appreciated.

Aaron

--


---------------------------------------------------------------------
"Are you still wasting your time with spam?...
There is a solution!"

Protected by GIANT Company's Spam Inspector
The most powerful anti-spam software available.
http://mail.spaminspector.com
 
C

Colo

Pls try like this.
*Put a Label control as a Label1 in the Userform1


Code:
--------------------

'Place the code below in Standard Module
Sub TestShowForm()
'// Change here to the path
Const URL As String = "http://www.interq.or.jp/sun/puremis/colo/home.htm"
With UserForm1
.WebBrowser1.Navigate URL
Do Until .WebBrowser1.ReadyState = 4
DoEvents
Loop
.Show
End With
End Sub

'Place the code below in UserForm Module
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
Me.Label1.Caption = Me.WebBrowser1.LocationURL
End Sub

--------------------
 
A

Aaron

Colo,
You are a champ! Thank you mate!
What I wanted to do is to load a path on my drive eg.explorer, which your
code works.
Is it possible to add a search button?



--


---------------------------------------------------------------------
"Are you still wasting your time with spam?...
There is a solution!"

Protected by GIANT Company's Spam Inspector
The most powerful anti-spam software available.
http://mail.spaminspector.com
 
C

Colo

Aaron, it can be done. :D

Put controls below in Userform1
Label1, Textbox1, CommandButton1,WebBrowser1

Pls have a look @ Attached file!


Code:
--------------------


'Place the code below in Standard Module
Sub TestShowForm()
'// Change here to the path
Const url As String = "http://www.excelforum.com/t178929-s"
With UserForm1
.WebBrowser1.Navigate url
Do Until .WebBrowser1.ReadyState = 4
DoEvents
Loop
.Show
End With
End Sub

'Place the code below in UserForm Module

Private Sub CommandButton1_Click()
Const urlGoogle As String = _
"http://www.google.com/search?hl=en&ie=UTF-8&oe=UTF-8&q="
Dim strKeyWrd As String
strKeyWrd = Replace(Me.TextBox1, " ", "+")
Me.WebBrowser1.Navigate urlGoogle & strKeyWrd
End Sub

Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, url As Variant)
Me.Label1.Caption = Me.WebBrowser1.LocationURL
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top