PDA

View Full Version : Solved: Webpages in Userforms?



samuelwright
11-25-2005, 08:45 AM
Hello all.:hi:

A 2 pronged query coming up...

1. Is it possible to have a Webpage (e.g. google) "embedded" into a userform that is opened in a Word Document? The reason I would like to do this is because it would be nice for the user to search the web within the confines of the Userform and not have to open a seperate window using a hyperlinked button. Note, I would like to have scroll bars along the side of the webpage so that the overal size can be kept quite small. Also, if the internet is not available, I dont want the userform to crash altogether.

2. Assuming it is possible to have an embedded webpage, is it possible to extract the title of the webpage being viewed and display it in say, a normal textbox at the click of a button?

Thank-you!!

Sam

Killian
11-25-2005, 09:14 AM
It's possible...
Right click your UserForn Toolbox, select Additional Controls and choose "Microsoft Web browser".
Now draw your WebBrowser control on the userform - there'll be a whole bunch of new properties and method to play with (like Navigate to go to a URL) and LocationName or LocationURL for your button click

Enjoy...

samuelwright
11-28-2005, 07:44 AM
Hi Killian

Wow! This is pretty cool! One problem I have been getting is that when I have a web browser on a multipage, it loads once during the initilaize event, then when I click on another multipage on the same userform, it seems to "dissappear" once I go back to the multipage with the web browser on it. I tried playing with the visible property, and also trying to reload it when I do a Multipage_change event, but to no avail. Do certain properties of the browser page need to be adjusted to keep it loaded?

Sam

Killian
11-28-2005, 09:30 AM
It is cool, isn't it? Unless of course you want to use one on a multipage, then things get a little less impressive...
The problem here is that the browser control renders in a child window of the mutipage when it's loaded (a window in the OS sense: a defined area of the system display area) and when you change the multipage tab, that child window is destroyed - taking the ActiveX control with it... unfortunate to say the least.

There are probably a number of ways around it, the obvious one being to use a tabstrip control and use it's change event to show/hide the browser control.

That said, I just tried it out and while it works, I was getting errors on occasion, which leads me to suspect that there may a number of state tests to make on the control before you can show it successfully - or it's just not very good... I'm inclined towards the latter at the moment (I've spent most of today cursing Microsoft for one reason or another) but I'll re-visit the situation later when I'm feeling more positive. :yes

samuelwright
11-28-2005, 09:41 AM
Thats ok, I realised that I didnt really need a multipage anyway...it makes the userform a little bit bigger, but that is no great problem. One way of getting rid of the problem!!

Cheers Killian!