getting createDocumentFromUrl() to work

P

Pat Mac

Does anyone have a working example of the HTMLDocument.createDocumentFromUrl
function?? The few examples I found on the net don't seem to work. Here's
a piece of code that seems to go through some unnecessary steps but was
supposed to work, but for me it throws an "unknown error" exception.

Any help would be appreciated.

Dim doc1 As mshtml.IHTMLDocument2 ' HTMLDocument()
Dim docU As New mshtml.HTMLDocument()
Dim doc2a As mshtml.IHTMLDocument2 'mshtml.HTMLDocument()
Dim doc2 As mshtml.IHTMLDocument2

Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnStart.Click

Try
doc1 = docU
doc2a = docU
doc2a.write("<html></html>")
doc2a.close()
'This is the line that generates the exception.
doc2 = doc1.createDocumentFromUrl("http://www.yahoo.com", "null")
While doc2.readyState <> "complete"
Application.DoEvents()
End While
Catch ex As Exception
MsgBox(ex.Message)
End Try

End Sub
 
C

Cor

Hi Pat,

I never used it in that way, but when I see that Yahoo link you use, I think
that you are not on the right route.

If it would work, I think that the HTMLDocument.createDocumentFromUrl would
needed a full path. But I have no expirience with that and maybe I am wrong,
but because of the nature of the HTMLDocument I think that it is than very
close to it.

The HTMLDocument is always one document. So if a page exist of more
documents (frames) only one "HTML" document can exist in a HTMLDocument,
that is includes by instance the on page javascript but not things as
pictures and so.

You ask ask for "http//www.yahoo.com" that is the site not a document.

When you want to do like you do above, I would take a look for the
"webbrowser" class.

Maybe not the answer you wanted, but because there was no other, I think
when it is wrong, I will not be far beside it.

I hope this helps a little bit?

Cor,
 

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