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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

redirect screen to a file

Status
Not open for further replies.

peterd51

Technical User
Feb 22, 2005
109
GB
Hi,

we have a database that outputs in html and starts IE to display...

I'd like to send the output to a file so that I can read it in to a VB5 program to extract bits of the data.

Any ideas about how I can redirect from the screen to a file in Windows XP?

Regards
Peter
 
Hi,

I've made some progress but the code that you gave me doesn't work for some reason...

<just a reminder here that I'm using VB5>

I Removed Microsoft Internet Controls from Components.
Then Added Microsoft Internet Controls to References.

code...
form_load
Call GetHTML 'skips over the 'if then'.

Call GetHTML("e:\website\index.html") 'skips over the 'if then'.

Call GetHTML("Browser") 'gives an error:

runtime error 438: object doesn't support this property or method (...on the 'gethtml = line')
end code...

So I played around with the WebBrowser and finished up with:

Private Sub Form_Load()
Open "d:\browser.txt" For Input As #1
Input #1, xfer1 ' = e:\website\index.html
Input #1, xfer2 ' = blank for now
Close #1
WebBrowser1.Navigate2 (xfer1)
End Sub

Private Sub WebBrowser1_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
Number = WebBrowser1.Document.links.length
List1.AddItem "links = " & Number
List1.AddItem " "

For n = 0 To Number - 1
List1.AddItem WebBrowser1.Document.links(n).href
Next n

images = WebBrowser1.Document.images.length
List1.AddItem " "
List1.AddItem "images = " & images

List1.AddItem " "
For n = 0 To images - 1
List1.AddItem WebBrowser1.Document.images(n).href
Next n

List1.AddItem " "
List1.AddItem "pdisp = " & pDisp

List1.AddItem " "
List1.AddItem "url = " & URL


End Sub

' first attempt that didn't work...
'Private Sub Form_Load()
'Call GetHTML("Browser")
'Call GetHTML("e:\website\images.html")
'end sub

'Private Function GetHTML(strBrowserCaption As String) As String
' Dim ExplorerWindows As ShellWindows
' Dim BrowserWindow As WebBrowser

' Set ExplorerWindows = New ShellWindows

' For Each BrowserWindow In ExplorerWindows
' If BrowserWindow.LocationName = strBrowserCaption Then
' GetHTML = BrowserWindow.Document.body.parentNode.outerhtml
' End If
' Next
'End Function

end code....

This loads the selected page and lists the links and images.

I have to load the URL from a file as I can't use the IDE at work so I have to compile an .exe at home and run it at work...and I need to be able to select different URL's while testing.

I didn't know last night how to get into the text but looking around the internet this morning I found the .innertext .outertext commands so I'll try these over the weekend.

I can't find a list of any Webbrowser1.Document. commands... any ideas where I might get one. If I know all of the possible extensions after 'document.' then I can play around until I get something usable.

Regards
Peter

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top