
Saving Pages Using the WebBrowser Control ???
I've been trying to develop a simple VB5 app that will hook into a running
Internet Explorer 4 application. I've included the WebBrowser
(InternetExplorer) control in my project and this has allowed me access to
IE4. The main goal of my simple VB app is to save Web pages in the same
manner that one can do currently using the "Save" option under "File" in
IE4.
What I would like to know how to do is "Save" the current page displayed in
IE4, so I'm guessing that I would have to use the IE4 "Save" or "SaveAs"
hooks available in the WebBrowser control.
I've recently read an article from the MS Knowledge Base concerning a
similar technique pertaining to the "Print" IE4 option. I incorporated the
code from this article into my app and printing now works great. However,
I'm trying to adapt that procedure to perform "Save", but I've been
unsuccessful. I don't know what the deal is.
Here's what the "Print" code looks like:
' m_iehook is a WebBrowser object (defined elsewhere)
Dim myOleCmdId As OLECMDID
myOldCmdId = OLECMDID_PRINT
eQuery = m_iehook.QueryStatusWB(myOleCmdId)
If Err.Number = 0 Then
If eQuery And OLECMDF_ENABLED Then
m_iehook.ExecWB myOleCmdId, OLECMDEXECOPT_PROMPTUSER, "", ""
Else
MsgBox "eQuery Error: " & Err.Description
End If
End If
If Err.Number <> 0 Then
MsgBox "Command Error: " & Err.Description
End If
Of course there is a whole mess of OLECMDID constants defined in the
WebBrowser control that I would expect to behave the same way as print.
However, the only ones that I can get to work without error are:
OLECMDID_PRINT
OLECMDID_REFRESH
OLECMDID_UPDATECOMMANDS
What I'd really like is obviously OLECMDID_SAVE, but when I try this method,
'eQuery And OLECMDF_ENABLED' returns 'False' and fails. If I try to force
the ExecWB, I get "Method of 'ExecWB' of object 'IWebBrowser2' failed".
I don't understand why the QueryStatusWB() is not giving me OLECMDF_ENABLED
for OLECMDID_SAVE. I guess that I'm not completely sure even what I'm asking
with QueryStatusWB().
Any thoughts, ideas, or solutions would be greatly appreciated!
Darin Boesch