Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 171
  • Last Modified:

Can I capture the source brought in by a Webbrowser Control

I have a MS Webbrowser control on a form.
When the page is finished loading, can I save the SOURCE code of the page to a text file?
How?
Example?
0
yyuubum2
Asked:
yyuubum2
  • 3
1 Solution
 
PhilAICommented:
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
Call SendKeys("C:\Test.html" + "{ENTER}", 0)
Call WebBrowser1.ExecWB(OLECMDID_SAVEAS, OLECMDEXECOPT_DONTPROMPTUSER, 0, 0)
End Sub
0
 
PhilAICommented:
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)

Call SendKeys("C:\Test1.html" + "{ENTER}", 0)
Call WebBrowser1.ExecWB(OLECMDID_SAVEAS, OLECMDEXECOPT_DONTPROMPTUSER, 0, 0)

' or: use either the code above this line or below it...

Dim iFile As Integer

iFile = FreeFile
Open "c:\Test2.html" For Output As #iFile
Print #iFile, WebBrowser1.Document.All(0).outerHTML
Close #iFile

End Sub
0
 
yyuubum2Author Commented:
how do I make:
Call SendKeys("C:\Test1.html" + "{ENTER}", 0)
not require "overwrite confirmation" ?
0
 
PhilAICommented:
Delete the file first?

Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)

On Error Resume Next

Call Kill("C:\Test1.html")
Call SendKeys("C:\Test1.html" + "{ENTER}", 0)
Call WebBrowser1.ExecWB(OLECMDID_SAVEAS, OLECMDEXECOPT_DONTPROMPTUSER, 0, 0)

End Sub
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now