Using a web browser control

R

Ron Weiner

I have never used a WebBrowser control in an Access App, but I do have one
commercial VB app that uses it. We have had success with hundreds (probably
thousands by now) of users that have been able to use the application
without ANY kind of install.

Our minimum requirements for the application are Win2K and higher, IE-4 and
higher and an available USB port. The Win2K and higher requirement insure
that the VB6 runtime is there, and the IE-4 and higher requirement insures
that the WebBrowser control is available. The app is distributed on a USB
flash memory drive and often times is run directly from there without any
kind of installation being performed on the host computer.

Soooo....

1, Yes but not in Access
2, I haven't the faintest.
3, It is IMHO neither a good or bad thing, but an "All Right" thing.
4, To date we have not had a single issue. How many PC's running windows do
you think are out there that do not have IE installed. I suspect not to
many.
5, If I needed some functionality that the WB control provides that I could
not get using native Access controls I'd use it.
 
F

Fred Boer

Dear Ron:

Thanks for the answers! I am experimenting with the control. BTW... I can't
find documentation on the control's events; Access lists some but not all of
them (at least, it doesn't list all that are shown in the procedure dropdown
combobox in the VBA IDE). Where do I find documentation on this control?

Thanks!
Fred Boer
 
R

Ron Weiner

I guess this should be the more or less official place for the documentation
http://msdn.microsoft.com/library/d...wser/webbrowser/browser_control_ovw_entry.asp
However I have found that some of the stuff in the documentation provided by
Microsoft either does not work at all, or doesn't work exactly as
advertised.

Ahhh... Hell who knows maybe its me.

By Google-ing "WebBrowser control events" I got a tad over 3 million hits.
I am comfortable that by starting with the Microsoft reference above and
then Google-ing for answers to more specific requests when you have
problems, you should probably be OK.
 
D

Dirk Goldgar

Fred Boer said:
Hello!

Well, I've been doing a bit 'o research about using web pages as a
source of book cataloguing data, and I found an example of a form
which uses a "Web Browser Control". Well, I've never heard of such a
thing but it looks interesting. I was easily able to stick a control
on a form and have it display a web page. But I can't recall *ever*
seeing a post that mentions this control...

1. Has anybody used this control?
2. Why have I never seen any posts relating to its use?
3. Is is a good/bad thing?
4. I see it is an Active X control - that's a bad thing 'cause it
leads to DLL issues? Right? or is that overstating things...
5. Any particular hints/suggestions/cautions about such a control?

Fred, I haven't done much with that control except poke it to see how it
works. If you need access to the document model of the returned web
page, that's probably the way to go. An alternative, if you care to
parse the returned HTML yourself, is the Internet Transfer Library
posted at:

http://www.mvps.org/access/modules/mdl0037.htm

I've used that to run web queries for which I parsed the results myself.
It's simpler, because there's no display functionality there at all --
it just gets the HTML: that is returned from the URL and presents it as
a string.
 
F

Fred Boer

Dear Dirk:

Thanks for the link. I will take a look at it. In another thread, Doug
Steele suggested the approach listed in one of his SmartAccess columns
(http://www.accessmvp.com/DJSteele/SmartAccess.html November 2003). I could
be mistaken, but I wonder if your suggestion will present the same
difficulty that I believe exists with Doug's suggestion: it is assumed that
the URL is known before the process begins. In my situation, the URL will
change in each instance. If it won't bore you, perhaps I might outline what
I "really want to do".. ;)

I want to retrieve book cataloguing information from the Library of Congress
(Cataloguing books myself? .. ugh.. yuck...ptui!...), so I:

1. Go to the Library of Congress Z39.50 search web page:

http://www.loc.gov/cgi-bin/zgate?AC...950/locils1.html,z3950.loc.gov,7090&CI=121347

2. Enter a title, for example, "My family and other animals".
3. Pick "More on this record" for (say) the first record displayed.
4. "Scrape" this web page's text, parse and insert into appropriate fields
in my waiting form.

Now, I suppose I can envision how to "scrape" the text from the web page
(using Doug's method, or possibly your suggestion), and the parsing of the
text should be straightforward enough (well, it'll challenge *me*...) BUT...
I need a way to say "Ok, computer, go to the web page that is being
displayed in the browser at this particular moment and scrape the
information from that specific web page". That is why I was thinking of the
Web Browser Control, 'cause I thought I might be able to refer to it in that
way...

Now, I haven't tried really hard yet to implement anything, since I don't
want to head down a dead end...

Thanks!
Fred
 
D

Douglas J Steele

Actually, Fred, having looked at the example you just gave, I think you will
have to use the Browser control.

I'm going to play around with it a little while. I'll post back here later
today.
 
F

Fred Boer

Thanks, Doug!

Fred

Douglas J Steele said:
Actually, Fred, having looked at the example you just gave, I think you
will
have to use the Browser control.

I'm going to play around with it a little while. I'll post back here later
today.
 
F

Fred Boer

Apologies proffered for my incorrect computer clock! (That's twice within a
week! If it happens again, I'm gonna freak!!)

Fred Boer
 
D

Dirk Goldgar

Fred Boer said:
Dear Dirk:

Thanks for the link. I will take a look at it. In another thread, Doug
Steele suggested the approach listed in one of his SmartAccess columns
(http://www.accessmvp.com/DJSteele/SmartAccess.html November 2003). I
could be mistaken, but I wonder if your suggestion will present the
same difficulty that I believe exists with Doug's suggestion: it is
assumed that the URL is known before the process begins. In my
situation, the URL will change in each instance. If it won't bore
you, perhaps I might outline what I "really want to do".. ;)

I want to retrieve book cataloguing information from the Library of
Congress (Cataloguing books myself? .. ugh.. yuck...ptui!...), so I:

1. Go to the Library of Congress Z39.50 search web page:

http://www.loc.gov/cgi-bin/zgate?AC...950/locils1.html,z3950.loc.gov,7090&CI=121347

2. Enter a title, for example, "My family and other animals".
3. Pick "More on this record" for (say) the first record displayed.
4. "Scrape" this web page's text, parse and insert into appropriate
fields in my waiting form.

Now, I suppose I can envision how to "scrape" the text from the web
page (using Doug's method, or possibly your suggestion), and the
parsing of the text should be straightforward enough (well, it'll
challenge *me*...) BUT... I need a way to say "Ok, computer, go to
the web page that is being displayed in the browser at this
particular moment and scrape the information from that specific web
page". That is why I was thinking of the Web Browser Control, 'cause
I thought I might be able to refer to it in that way...

Now, I haven't tried really hard yet to implement anything, since I
don't want to head down a dead end...

Hmm, that's going to be a tricky, because the web site uses an HTML
form and the POST method, so you can't just send a GET request with a
query string. Once you get the actual page you want, whether it's
displayed in a web browser(and whether that's in a Web Browser control
or in an independent IE window) or even a simple string containing the
HTML, it would be easy to parse its contents. But I don't see
immediately how to automate a query. Probably you can do it using the
XMLHTTP object or some such, but I don't know much about that. Doug
will probably be a better source for that.

On the other hand, this whole web site is a front for some sort of query
interface called Z39.50. Reading over some of the material linked by
that page and in other pages that Google turns up, I get the impression
that you may be able to run your queries directly through this interface
and protocol. I haven't done enough research to know how complicated it
is to make queries that way, but I do see, at

http://www.niso.org/z39.50/z3950.html#software

that there's reason to believe there may be free software available.
 
D

Dirk Goldgar

1. Go to the Library of Congress Z39.50 search web page:

This whole question was looking oddly familiar. Seems to me I looked
into Z39.50 for you a while back, in a prospective sort of way.
 
F

Fred Boer

Hi Dirk:

Well, I don't know from POST and GET, so I'm happy to see if Doug can come
up with something...

Actually, I was aware that Z39.50 was a searching interface, Dirk. I have
done a bit of reading and googling in the past and recently, hoping to turn
up something at a level I could cope with, but from what I've read/seen so
far, it is beyond me! I am aware that professional book cataloguing and
library administration systems incorporate the kind of cataloguing process I
want, but, of course, I'm trying to do it on my own for free. At the moment,
I'm open to all possibilities, and am also making enquiries among some other
librarians about Z39.50... but I've gotten nowhere with Z39.50 so far. It is
probably the case that, even if I managed to find some sort of free Z39.50
software, it would end up being web-based anyway. I will certainly be
looking at the links on the page you provide, however!

Thanks very much!
Fred
 
P

PC Datasheet

Hi Fred,

From my file ----
Launch A Browser From An Access Form And Go Straight To A Specified Web Site

http://www.datapigtechnologies.com/flashfiles/webbrowserctrl.html

Initialize Microsoft Web Browser Control

The Microsoft Web Browser control needs to be initalized by browsing to
"about:blank" before you go to use it for the first time. I recommend that
in the Foem_Load event yo add some code like:

Define this constant somewhere in the General section of the forms code

Const NAV_NO_HISTORY = &H2

Then in the Foem_Load() event add this

' Initalize Browser control by navigating to nowhere
wbMain.Navigate "about:blank", NAV_NO_HISTORY

Once that is done I have found that I am able to manulipate the control and
all of its properties without error.


Set What The Microsoft Web Brower Control Displays

Example:

Pictures are in files that have been uploaded to an internet site. The
pictures can be displayed with:

Me!NameOfWebBrowserControl.Navigate2 _
"http://www.myinternetsite.com/mysubfolder.gif"


--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com

If you don't get the help you need in the newsgroup, I can help you for a
very reasonable fee. Over 1000 Access users have come to me for help.
 
F

Fred Boer

Dirk, your memory serves you well.. now that you mention it, yes, I *do*
remember mentioning Z93.50 to you once upon a time. It's one of those things
that I go back and forth on.. I get excited about the possibilities, and
then I do some research and get overwhelmed at the complexities... I had
long ago given up on the idea of downloading cataloguing, but then Doug made
a comment in a post about pulling information from a website and it got me
going on it again..

It's just one of those things that seems so desirable, and then turns out to
be too big a challenge. I'm like Tantalus, I see the grapes, they look
delicious, but then I reach for them they are just beyond my fingertips...

Fred
 
F

Fred Boer

What!? I thought you'd be done by now! ;)

Seriously, please don't spend any more time or effort on this than you want,
Doug! I'm in no hurry, and, well, it isn't mission critical. And as far as
my wife and kids are concerned it ain't even mission necessary!!

Fred
 
A

Amy Blankenship

Dirk Goldgar said:
Hmm, that's going to be a tricky, because the web site uses an HTML
form and the POST method, so you can't just send a GET request with a
query string. Once you get the actual page you want, whether it's
displayed in a web browser(and whether that's in a Web Browser control
or in an independent IE window) or even a simple string containing the
HTML, it would be easy to parse its contents. But I don't see
immediately how to automate a query. Probably you can do it using the
XMLHTTP object or some such, but I don't know much about that. Doug
will probably be a better source for that.

Certain Macromedia products, such as Authorware, Flash, and Director, have
functions that let you call web pages with a post method in the background,
without ever needing to display the text anywhere. There's an authorware
example at my site www.authorware-amy.com on the examples page which you may
find useful if you have Authorware or this project is important enough for a
$3K software purchase (you can also download a trial). Authorware and, I
think, Director can run queries against a local Access DB. I think Flash is
limited to what it can do locally, but you can put the DB on a server and
use ASP to write from any of these products.

Not sure if this helps at all, but it's another way to think about the
problem.

Amy Blankenship
Team Macromedia for Authorware
 
D

Douglas J. Steele

Hey, it worked really well!

Create a form and add a Web Browser to it (you can use the Insert | ActiveX
Control... from the menu, and scroll through until you find the Microsoft
Web Browser entry) I chose to rename the control ocxBrowser.

Add code to navigate to the URL. I chose to add a button, cmdGotoURL, with
the following code:

Private Sub cmdGotoURL_Click()
On Error GoTo Err_cmdGotoURL_Click

Dim strURL As String

strURL =
"http://www.loc.gov/cgi-bin/zgate?AC...950/locils1.html,z3950.loc.gov,7090&CI=121347"
Me.ocxBrowser.Navigate strURL

End_cmdGotoURL_Click:
Exit Sub

Err_cmdGotoURL_Click:
MsgBox Err.Number & ": " & Err.Description & vbCrLf & vbCrLf & _
"Occurred in cmdGotoURL_Click"
Resume End_cmdGotoURL_Click

End Sub

Add another button cmdGetHTML with the following code:

Private Sub cmdGetHTML_Click()
On Error GoTo Err_cmdGetHTML_Click

Debug.Print Me.ocxBrowser.Document.documentElement.innerText

End_cmdGetHTML_Click:
Exit Sub

Err_cmdGetHTML_Click:
MsgBox Err.Number & ": " & Err.Description & vbCrLf & vbCrLf & _
"Occurred in cmdGetHTML_Click"
Resume End_cmdGetHTML_Click

End Sub

Fire up the form, and click on the cmdGotoURL button. That'll bring up the
Library of Congress search form in the browser you put on the form. Enter
"My family and other animals" in the Search Terms box, then click on the
Submit Query button. The results will appear on the browser. Click on the
cmdGetHTML button, then look in the Debug window. You should see:

VOYAGER[my family and other animals[1,4,2,3,3,1,4,1,5,1,6,1]]Query Results
Records 1 through 3 of 3 returned.


Author: Durrell, Gerald Malcolm, 1925-
Title: My family and other animals.
Published: New York, Viking Press, 1957 [c1956]
LC Call No.: QH151.D8 1956a

More on this record


Author: Durrell, Gerald Malcolm, 1925-
Title: My family and other animals.
Published: London, Hart-Davis, 1956
LC Call No.: QH151.D8 1956

More on this record


Author: Durrell, Gerald Malcolm, 1925-
Title: My family and other animals / Gerald Durrell.
Published: New York : Penguin Books, 2000.
LC Call No.: QH151.D8 2000

More on this record

Go back to the Search Form

This display was generated by the CNIDR Web-Z39.50 gateway, version 1.08,
with Library of Congress Modifications.

Hopefully you can parse that however you want.

Since this page uses the POST method to navigate to the next form, you could
probably use the concepts presented in
http://support.microsoft.com/?id=167658 to be able to do everything
programmatically (as opposed to having to key the information into the
browser and click on the Submit button). Sorry, too lazy to look into that
right now.
 

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