Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WebBrowser: automatic page saving

Status
Not open for further replies.

abbath8

Programmer
Sep 20, 2003
40
0
0
HU
Hi,

I have a problem. I wrote a program which contains a WebBrowser component. And I have a page which contains a dynamic IntraWeb dll. When the page is loaded the page shows the pictures and the text created by the dll.
I want to save this page automatically. There is a method "ExecWB", and this method can save the page with the appropriate parameters (Save or saveas). But it is always shows the save dialog box. Because of this I can't save the page in every 5 minutes or in custom periods.
Please help me, how to save the page periodically without prompting the user???
It's rather urgent...

Thanks!
 
I can't claim credit for this one. It came directly from Edanmo's VB page:
To save the page from a WebBrowser you usually use the ExecWB method, but it always shows the "Save As..." dialog.
If you want to save the source page without showing a dialog you need other method. The HTMLDocument object implements the IPersistFile interface that allows the document to be saved to a file.

The code to save the source looks like this:


Dim oPF As IPersistFile

Set oPF = WebBrowser1.Document

oPF.Save "TheFileNameHere.htm", False
 
Thanks, it works, but another problem is:
At the webbrowser.navigate method the program should wait for the complete page downloading and then continues. How to get the webbrowser to do this?
 
simple
just write the save part in the wb1_DownloadComplete() event
 
I'm also interested in saving the current web page programatically (where the user is not prompted) but I can't make the suggested solution work. My project does not seem to recognise the IPersistFile. Do I need some other resource loaded into my project eg dll?
 
You need Edanmo's OLE interfaces & functions type library (OLELIB.TLB), which is also available from the link CBrianA provided. It is a well worthwhile download. I've been using it for ages.
 
Sorry for the late reply. Thanks very much. I have eventually made this work. I initially had trouble making this work as I didn't know how to register the library types but I found a program "VBRegTLB6.exe" at vbaccelerator.com which works perfectly.
 
I have been trying to get this to work. I have downloadet Edanmo's OLE interfaces & functions type library, placed them in \winnt\system32\ and register them with VBRegTLB6.exe. But the code still does not work. Do i have to add something to my projekt? or how do i get Edanmos stuff in VB6

i am really new to vb6, so it might be a very simple solution.

This is the error i get:
"Compile error: User-defined type not defined"

thanks for the great forum :)
 
ok i solved my problem in another way, here is what i did:

Open "filename" For Output As #1
Dim source As String
source = Form1.WebBrowser.Document.documentElement.innerHTML


Print #1, source

Close #1
End If
 
I was wondering about that...

Or...
Code:
Open "FileName" For Output As #1
  Print WebBrowser.Document.Body.innerHTML
Close

But I thought you were talking about saving the picutures and all the content included...

I showed an example of how to get the source of an external browser window in this thread:
thread222-934916

See my first post...
May be of intrest... ;-)

(sorry for not posting sooner)


PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
oops... forgot the #1, in print #1, WebBrowser.Document.Body.innerHTML

O well... guess you already knew that ;-)


PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top