I’ve never used the WebBrowser Control before the other day, but now I can’t stop using it. I was trying to find a way to display a PDF on a userform. I kept messing with the Adobe controls, but not everyone in my office has Acrobat loaded. Then I read that you can use this WebBrowser control.
To put a Webbrowser control on a userform, right click the Control Toolbox and select Additional Controls
Scroll down to Microsoft Web Browser and put a check next to it.
Then you can drag the control onto your userform and control it just like an instance of InternetExplorer. I forgot all about my PDF project and put this new knowledge to some real use. Two ListBoxes, each with all 117 college football teams, and two WebBrowser controls. Selecting a team in a ListBox will bring up that team’s schedule.
Here’s the code behind the ListBoxes. It’s not quite right yet. Things get a little screwy when you start rapid-fire selecting teams. And, as always, automating IE is slow.
Private Sub ListBox1_Change()
Me.WebBrowser1.Navigate2 smURL & Me.ListBox1.Value
Loop Until Me.WebBrowser1.ReadyState = READYSTATE_COMPLETE
I really don’t know what the difference between Navigate and Navigate2 is, but the example I saw used Navigate2. Someday, I’ll have to learn the difference. You can download this example workbook: WebControl.zip