Putting the Microsoft WebBrowser to Work
Posted by Derek Mang on January 22nd, 2008
The Microsoft Webbrowser control (windows\system32\shdocvw.dll) may be included in the VBA controls toolbox and subsequently used to present web pages within a userform or other MS Office container.
I typically develop application “help” files using MS Frontpage and until recently have been using the FollowHyperlink method (Excel, Word) to present the help page using Internet Explorer. When this method is used, IE is fired up and presents information as expected with the machine-typical delay for application startup.
A recent development has changed my thinking some. Briefly stated, this VBA application is built within MS Outlook, and logs information against a background Excel spreadsheet. It’s built within Outlook because there’s a fair bit of email communication with other parties. One of the other parties provides status data via the internet, and also provides a reference number within their communication which is logged (a business rule).
Like many VBA applications, this one replaces a lot of manual effort, and one of the manual tasks was to navigate to the website mentioned above to check on the item status.
To simplify this task, I used a userform with a listbox and a Webbrowser control. When the form is displayed, a list of reference numbers is provided. Click on a listed item, and the Webbrowser “navigate2″ method is fired up with the URL (a constant previously captured) and reference number appended appropriately. The corresponding page is presented, and it’s a lot faster than instantiating IE!!. Click another list item and a new page is presented - all the while working within Outlook!
I am in the process of updating other applications to present their Help in a userform based webbrowser, for the same reasons (faster, less system overhead, cleaner desktop).
Another usage of the Webrowser control is also nearing completion. This one is a VBA Code view / print function with a twist - the twist being the ability to choose your own colour / font combination for keywords and phrases, as well as being able to add your own keywords and phases.
I have taken the time to capture VBA keywords (ie. Integer, Dim, Instr) along with HTML supported colours and font names into a simple MS Access database. To this, I’ve added a userform where you can manage the HTML attributes of the keyword or phrase (i.e. anything with a space is considered a phase - End If, End With for example).
The main userform provides dropdowns for the VBA project, object within the project (module, userform), and component within the object (sub, function), as well as the Webbrowser window for viewing the code.
Within the webbrowser window you can select text by dragging the mouse, or right-click to present a menu which includes the Print function among others.
It’s pretty much wrapped up. It’s also available to our PODA membership! If interested, please contact me and I’ll send you a copy.



January 31st, 2008 at 9:59 am
Hi, is it possible to receive the Access database containing the user form and the webbrowser?
giorgio_rovelli@virgilio.it
February 4th, 2008 at 7:51 pm
Hi
This is not quite ready, and is also restricted to PODA membership.
Sorry..
February 6th, 2008 at 12:27 am
Thanks Derek, how do you become a member?
February 8th, 2008 at 8:23 pm
Go to the PODA portal and go from there
February 9th, 2008 at 9:04 am
Oh that? Then I’m already a member
February 14th, 2008 at 4:03 pm
Ok then
Please tell me who you are and I’ll send it out via the PODA email.
Regards
Derek
February 26th, 2008 at 1:50 pm
Thank you Derek
My name is Giorgio Rovelli
I’m an energy manager in Italy that also doubles(out of necessity) as an Access Developer.
giorgio_rovelli@virgilio.it
February 26th, 2008 at 1:52 pm
Sorry for the delay in replying by the way but there’s no notifications from this site when someone posts in a participated thread.
June 18th, 2008 at 6:03 am
Hello Derek
I will love to get my hands on this and tweak to deliver updates & information from excel (and perhaps with your latest gem “managing custom variables”) . So much more elegant than launching new IE instance.
If you will please send me then thankyou for saving some substantial time. I can send back once working sweetly and quietly