run Internet explorer in VBA 2007 (EXCEL)

D

Dean

Hello, I am new to VBA and was just woundering if it is possible to
add a control on to a userform, where you can use the internet, I
looked at microsoft web browser control, but I am not sure how to do
it, could you help? Thanks
 
H

Harald Staff

Yep, very possible, and the webbrowser control is the way to go. But it's
just a reading pane, you must provide and code all browserbuttons and -menus
you would need.
If you're new to VBA, I suggest you don't start with this project, learn the
basics first.

Best wishes Harald
 
D

Dean

Yep, very possible, and the webbrowser control is the way to go. But it's
just a reading pane, you must provide and code all browserbuttons and -menus
you would need.
If you're new to VBA, I suggest you don't start with this project, learn the
basics first.

Best wishes Harald






- Show quoted text -

ok sure maybe I'm not that new, But i'm not the professional type
 
H

Harald Staff

Good. Set your VB editor to "Require variable declaration" so that it enters
Option Explicit into your modules.
Add the control to a userform and the top dropdowns + intellisense will
reveal all properties and methods you need to get started. Here are the
important five. Add Textbox1 (for URL entry). Commandbutton1 ("Go") and
Commandbutton2 ("Back"):

Option Explicit

Private Sub CommandButton1_Click()
WebBrowser1.Navigate2 (Me.TextBox1.Text)
End Sub

Private Sub WebBrowser1_BeforeNavigate2(ByVal pDisp As Object, _
URL As Variant, Flags As Variant, _
TargetFrameName As Variant, PostData As Variant, _
Headers As Variant, Cancel As Boolean)
Me.Caption = "Loading " & URL
End Sub

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

Private Sub WebBrowser1_StatusTextChange(ByVal Text As String)
Me.Caption = Text
End Sub

Private Sub CommandButton2_Click()
WebBrowser1.GoBack
End Sub

The control is useful for more than webbrowsing, see Dick's articles on
http://www.dailydoseofexcel.com/?s=webbrowser+control

HTH. Best wishes Harald


Yep, very possible, and the webbrowser control is the way to go. But it's
just a reading pane, you must provide and code all browserbuttons
and -menus
you would need.
If you're new to VBA, I suggest you don't start with this project, learn
the
basics first.

Best wishes Harald






- Show quoted text -

ok sure maybe I'm not that new, But i'm not the professional type
 
D

Dean

Good. Set your VB editor to "Require variable declaration" so that it enters
Option Explicit into your modules.
Add the control to a userform and the top dropdowns + intellisense will
reveal all properties and methods you need to get started. Here are the
important five. Add Textbox1 (for URL entry). Commandbutton1 ("Go") and
Commandbutton2 ("Back"):

Option Explicit

Private Sub CommandButton1_Click()
WebBrowser1.Navigate2 (Me.TextBox1.Text)
End Sub

Private Sub WebBrowser1_BeforeNavigate2(ByVal pDisp As Object, _
    URL As Variant, Flags As Variant, _
    TargetFrameName As Variant, PostData As Variant, _
    Headers As Variant, Cancel As Boolean)
Me.Caption = "Loading " & URL
End Sub

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

Private Sub WebBrowser1_StatusTextChange(ByVal Text As String)
Me.Caption = Text
End Sub

Private Sub CommandButton2_Click()
WebBrowser1.GoBack
End Sub

The control is useful for more than webbrowsing, see Dick's articles onhttp://www.dailydoseofexcel.com/?s=webbrowser+control

HTH. Best wishes Harald







ok sure maybe I'm not that new, But i'm not the professional type- Hide quoted text -

- Show quoted text -

Hey! thanks alot, not I am planning to add a list box for the hitory,
should I just use additem when you click the Go button, that shouldn't
be too hard, well once again, thanks
 
H

Harald Staff

Dean said:
news:7117a377-22c8-4c6d-98aa-> (e-mail address removed)...
Hey! thanks alot, not I am planning to add a list box for the hitory,
should I just use additem when you click the Go button, that shouldn't
be too hard, well once again, thanks

You're welcome.
Hard part would then be to save the history between excel shutdowns /
computer reboots. Do this by writing to / reading from a text file, ini
file, xml file, database, worksheet or similar. Web is full of samples.
Consider also not to save "Go" entries that are invalid -check the other
events for that. Maybe NavigateComplete2 or StatusTextChange is the place to
save instead.

Best wishes Harald
 
D

Dean

You're welcome.
Hard part would then be to save the history between excel shutdowns /
computer reboots. Do this by writing to / reading from a text file, ini
file, xml file, database, worksheet or similar. Web is full of samples.
Consider also not to save "Go" entries that are invalid -check the other
events for that. Maybe NavigateComplete2 or StatusTextChange is the placeto
save instead.

Best wishes Harald

oh, ok thanks
yea got the code to read and write .txt files on my other computer
but that is somewhere else
 

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