473,508 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

loading a url using mshtml.createDocumentFromUrl

Hello,
I am having certain problems in trying to use the function
createDocumentFromUrl in VB.NET but get this error.."Object reference not set
to an instance of object".
Here is the code that I am using

Imports mshtml

Public DocumentFactory As HTMLDocument
Public Function GetWebPage(ByVal strURL As String) As HTMLDocument
Try
GetWebPage = DocumentFactory.createDocumentFromUrl(strURL, vbNullString)
StatusBar1.Panels(1).Text = strURL
Do Until GetWebPage.readyState = "complete"
Application.DoEvents()
Loop
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Function

I was reading through the similar situation but the gentleman posting the
reply has submiited a attachment which is not be found anymore. I would
greatly apprecitate if the code is posted again.

Thanking you in advance,

Vibhu Bansal.
Nov 21 '05 #1
14 7449
Further to my post, I need to use IPersistStreamInit. I was reading this in
this forum itself. But unfortunately, the solution file posted as an
attachment is missing. I would request anybody who has a clue to it to get
asap.
Vibhu Bansal.
Nov 21 '05 #2
Further to my post, I need to use IPersistStreamInit. I was reading this in
this forum itself. But unfortunately, the solution file posted as an
attachment is missing. I would request anybody who has a clue to it to get
asap.
Vibhu Bansal.
Nov 21 '05 #3
Hi Charles,
It seems that the attachment is not getting posted. Please email the
attachment to me at vi****@hotmail.com if you can.
BTW, the gentleman is you itself and I was reading the post sometime of late
last year within this forum.
Vibhu.

"Charles Law" wrote:
Hi Vibhu
I was reading through the similar situation but the gentleman posting the
reply has submiited a attachment which is not be found anymore. I would
greatly apprecitate if the code is posted again.


Do you know the Gentleman's name, and when it was posted?
GetWebPage = DocumentFactory.createDocumentFromUrl(strURL,
vbNullString)


The problem is here because DocumentFactory has not been created yet.

Try the attached.

HTH

Charles
"Vibhu Bansal" <Vibhu Ba****@discussions.microsoft.com> wrote in message
news:50**********************************@microsof t.com...
Hello,
I am having certain problems in trying to use the function
createDocumentFromUrl in VB.NET but get this error.."Object reference not
set
to an instance of object".
Here is the code that I am using

Imports mshtml

Public DocumentFactory As HTMLDocument
Public Function GetWebPage(ByVal strURL As String) As HTMLDocument
Try
GetWebPage = DocumentFactory.createDocumentFromUrl(strURL,
vbNullString)
StatusBar1.Panels(1).Text = strURL
Do Until GetWebPage.readyState = "complete"
Application.DoEvents()
Loop
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Function

I was reading through the similar situation but the gentleman posting the
reply has submiited a attachment which is not be found anymore. I would
greatly apprecitate if the code is posted again.

Thanking you in advance,

Vibhu Bansal.


Nov 21 '05 #4
Hi Charles,
It seems that the attachment is not getting posted. Please email the
attachment to me at vi****@hotmail.com if you can.
BTW, the gentleman is you itself and I was reading the post sometime of late
last year within this forum.
Vibhu.

"Charles Law" wrote:
Hi Vibhu
I was reading through the similar situation but the gentleman posting the
reply has submiited a attachment which is not be found anymore. I would
greatly apprecitate if the code is posted again.


Do you know the Gentleman's name, and when it was posted?
GetWebPage = DocumentFactory.createDocumentFromUrl(strURL,
vbNullString)


The problem is here because DocumentFactory has not been created yet.

Try the attached.

HTH

Charles
"Vibhu Bansal" <Vibhu Ba****@discussions.microsoft.com> wrote in message
news:50**********************************@microsof t.com...
Hello,
I am having certain problems in trying to use the function
createDocumentFromUrl in VB.NET but get this error.."Object reference not
set
to an instance of object".
Here is the code that I am using

Imports mshtml

Public DocumentFactory As HTMLDocument
Public Function GetWebPage(ByVal strURL As String) As HTMLDocument
Try
GetWebPage = DocumentFactory.createDocumentFromUrl(strURL,
vbNullString)
StatusBar1.Panels(1).Text = strURL
Do Until GetWebPage.readyState = "complete"
Application.DoEvents()
Loop
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Function

I was reading through the similar situation but the gentleman posting the
reply has submiited a attachment which is not be found anymore. I would
greatly apprecitate if the code is posted again.

Thanking you in advance,

Vibhu Bansal.


Nov 21 '05 #5
Vibhu,

It is in the newsgroup, what you can try is to attach this newsgroup direct
on the microsoft.newsserver
news://news.microsoft.com/microsoft....t.languages.vb

As well to inform Charles from that.

Cor
Nov 21 '05 #6
Vibhu,

It is in the newsgroup, what you can try is to attach this newsgroup direct
on the microsoft.newsserver
news://news.microsoft.com/microsoft....t.languages.vb

As well to inform Charles from that.

Cor
Nov 21 '05 #7
I have just sent it so you should receive it shortly.

I am able to see the attachment on the newsgroup using MS Outlook Express as
my newsreader, so perhaps it is something at your end that is preventing you
from seeing it.

Charles
"Vibhu Bansal" <Vi*********@discussions.microsoft.com> wrote in message
news:72**********************************@microsof t.com...
Hi Charles,
It seems that the attachment is not getting posted. Please email the
attachment to me at vi****@hotmail.com if you can.
BTW, the gentleman is you itself and I was reading the post sometime of
late
last year within this forum.
Vibhu.

"Charles Law" wrote:
Hi Vibhu
> I was reading through the similar situation but the gentleman posting
> the
> reply has submiited a attachment which is not be found anymore. I would
> greatly apprecitate if the code is posted again.


Do you know the Gentleman's name, and when it was posted?
> GetWebPage = DocumentFactory.createDocumentFromUrl(strURL,
> vbNullString)


The problem is here because DocumentFactory has not been created yet.

Try the attached.

HTH

Charles
"Vibhu Bansal" <Vibhu Ba****@discussions.microsoft.com> wrote in message
news:50**********************************@microsof t.com...
> Hello,
> I am having certain problems in trying to use the function
> createDocumentFromUrl in VB.NET but get this error.."Object reference
> not
> set
> to an instance of object".
> Here is the code that I am using
>
> Imports mshtml
>
> Public DocumentFactory As HTMLDocument
> Public Function GetWebPage(ByVal strURL As String) As HTMLDocument
> Try
> GetWebPage = DocumentFactory.createDocumentFromUrl(strURL,
> vbNullString)
> StatusBar1.Panels(1).Text = strURL
> Do Until GetWebPage.readyState = "complete"
> Application.DoEvents()
> Loop
> Catch ex As Exception
> MsgBox(ex.Message)
> End Try
> End Function
>
> I was reading through the similar situation but the gentleman posting
> the
> reply has submiited a attachment which is not be found anymore. I would
> greatly apprecitate if the code is posted again.
>
> Thanking you in advance,
>
> Vibhu Bansal.
>
>


Nov 21 '05 #8
I have just sent it so you should receive it shortly.

I am able to see the attachment on the newsgroup using MS Outlook Express as
my newsreader, so perhaps it is something at your end that is preventing you
from seeing it.

Charles
"Vibhu Bansal" <Vi*********@discussions.microsoft.com> wrote in message
news:72**********************************@microsof t.com...
Hi Charles,
It seems that the attachment is not getting posted. Please email the
attachment to me at vi****@hotmail.com if you can.
BTW, the gentleman is you itself and I was reading the post sometime of
late
last year within this forum.
Vibhu.

"Charles Law" wrote:
Hi Vibhu
> I was reading through the similar situation but the gentleman posting
> the
> reply has submiited a attachment which is not be found anymore. I would
> greatly apprecitate if the code is posted again.


Do you know the Gentleman's name, and when it was posted?
> GetWebPage = DocumentFactory.createDocumentFromUrl(strURL,
> vbNullString)


The problem is here because DocumentFactory has not been created yet.

Try the attached.

HTH

Charles
"Vibhu Bansal" <Vibhu Ba****@discussions.microsoft.com> wrote in message
news:50**********************************@microsof t.com...
> Hello,
> I am having certain problems in trying to use the function
> createDocumentFromUrl in VB.NET but get this error.."Object reference
> not
> set
> to an instance of object".
> Here is the code that I am using
>
> Imports mshtml
>
> Public DocumentFactory As HTMLDocument
> Public Function GetWebPage(ByVal strURL As String) As HTMLDocument
> Try
> GetWebPage = DocumentFactory.createDocumentFromUrl(strURL,
> vbNullString)
> StatusBar1.Panels(1).Text = strURL
> Do Until GetWebPage.readyState = "complete"
> Application.DoEvents()
> Loop
> Catch ex As Exception
> MsgBox(ex.Message)
> End Try
> End Function
>
> I was reading through the similar situation but the gentleman posting
> the
> reply has submiited a attachment which is not be found anymore. I would
> greatly apprecitate if the code is posted again.
>
> Thanking you in advance,
>
> Vibhu Bansal.
>
>


Nov 21 '05 #9
Hi Charles,
Thanks for the info. Now I am getting stuck up in the next part i.e. using
this fuction, I need to get all elements by their tag names. So in VB6, I was
using the function getElementsbyTagname. But now as the page is being
retrieved in IHTMLDocument2 object, it does not support this function. Can
you provide me hints as to how I can use this functionality. I need to use
this function to look for images and store them on the local folder in the
harddisk.
Any help or references would be greatly beneficial.
Thanking You,
Vibhu.
Nov 21 '05 #10
Hi Charles,
Thanks for the info. Now I am getting stuck up in the next part i.e. using
this fuction, I need to get all elements by their tag names. So in VB6, I was
using the function getElementsbyTagname. But now as the page is being
retrieved in IHTMLDocument2 object, it does not support this function. Can
you provide me hints as to how I can use this functionality. I need to use
this function to look for images and store them on the local folder in the
harddisk.
Any help or references would be greatly beneficial.
Thanking You,
Vibhu.
Nov 21 '05 #11
Vibhu

getElementsByTagName is defined on the IHTMLDocument3 interface. Use
DirectCast to get this interface from the document object and you will then
be able to call the method as before.

HTH

Charles
"Vibhu Bansal" <Vi*********@discussions.microsoft.com> wrote in message
news:33**********************************@microsof t.com...
Hi Charles,
Thanks for the info. Now I am getting stuck up in the next part i.e. using
this fuction, I need to get all elements by their tag names. So in VB6, I
was
using the function getElementsbyTagname. But now as the page is being
retrieved in IHTMLDocument2 object, it does not support this function. Can
you provide me hints as to how I can use this functionality. I need to use
this function to look for images and store them on the local folder in the
harddisk.
Any help or references would be greatly beneficial.
Thanking You,
Vibhu.

Nov 21 '05 #12
Vibhu

getElementsByTagName is defined on the IHTMLDocument3 interface. Use
DirectCast to get this interface from the document object and you will then
be able to call the method as before.

HTH

Charles
"Vibhu Bansal" <Vi*********@discussions.microsoft.com> wrote in message
news:33**********************************@microsof t.com...
Hi Charles,
Thanks for the info. Now I am getting stuck up in the next part i.e. using
this fuction, I need to get all elements by their tag names. So in VB6, I
was
using the function getElementsbyTagname. But now as the page is being
retrieved in IHTMLDocument2 object, it does not support this function. Can
you provide me hints as to how I can use this functionality. I need to use
this function to look for images and store them on the local folder in the
harddisk.
Any help or references would be greatly beneficial.
Thanking You,
Vibhu.

Nov 21 '05 #13
Hi,
Instead of using getElementsbytagname, within IHTMDocument2 I stumbled on a
function of anchors. This is what the code looks like now...

Private Sub SearchUrl(ByVal strURL As String)
Dim objMSHTML As New mshtml.HTMLDocument
Dim objDocument As mshtml.IHTMLDocument2
Dim ips As IPersistStreamInit
Dim item As mshtml.IHTMLElement
ips = DirectCast(objMSHTML, IPersistStreamInit)
ips.InitNew()
objDocument = objMSHTML.createDocumentFromUrl(strURL, vbNullString)
Do Until objDocument.readyState = "complete"
Application.DoEvents()
Loop
For Each item In objDocument.anchors
Dim strUrl1 As mshtml.IHTMLAnchorElement
strUrl1 = item
MsgBox(strUrl1.href)
Next
End Sub
Now when this function is called, it does loop through objDocument.anchors
but shows a message box without any details. This is happening because it
seems that
objDocument's state is still not complete. I reached this inference because
the text in the text box is displayed after the message box has clicked on.

Any clues on why this is happening.

Vibhu.
Nov 21 '05 #14
Hi,
I finally got the problem working. Here is the solution...

We do need use IHTMLDocument3 in order to get the links with a page that has
been loaded.

Thanks Charles for the help you provided.

Private Sub SearchUrl(ByVal strURL As String)
Dim objMSHTML As New mshtml.HTMLDocument
Dim objDocument As mshtml.IHTMLDocument2
Dim ips As IPersistStreamInit
Dim HTMLTagCollection As mshtml.IHTMLElementCollection
Dim item As mshtml.IHTMLAnchorElement
ips = DirectCast(objMSHTML, IPersistStreamInit)
ips.InitNew()
objDocument = objMSHTML.createDocumentFromUrl(strURL, vbNullString)
Do Until objDocument.readyState = "complete"
Application.DoEvents()
Loop
TextBox1.Text = objDocument.body.innerHTML()
Dim ObjDocument3 As mshtml.IHTMLDocument3
ObjDocument3 = DirectCast(objDocument, mshtml.IHTMLDocument3)
HTMLTagCollection = ObjDocument3.getElementsByTagName("A")
For Each item In HTMLTagCollection
MsgBox(item.href)
Next
End Sub
Nov 21 '05 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
21268
by: BKM | last post by:
I've been using the following 2 ways to make sure my WebBrowser is finished loading a page before continuing with the next code. do:doevents:loop while WebBrowser.Busy do:doevents:loop until...
0
1453
by: travisGatesMcGee | last post by:
For days and days, I have been trying to see a URL's parsing in a DOM tree (links collection, images and other DHTML elements) in Visual Basic......... Total Disaster!!!!!!!!!! Way too many...
3
3463
by: Thomas Seidel | last post by:
Hi NG, I would like to write a specific library that gets it data from a specific webpage. Because not all web sites are XHTML I guess I have to use the old com library MSHTML. Beacause it...
2
3750
by: DotNetShadow | last post by:
Hi Guys, I have been reading heaps of information in regards to MSHTML object being used in .NET applications, windows and UI-less. I have read the walkall samples and tried various techniques...
3
2751
by: DotNetShadow | last post by:
Hi Guys, I have been reading heaps of information in regards to MSHTML object being used in .NET applications, windows and UI-less. I have read the walkall samples and tried various techniques...
3
5048
by: ddd | last post by:
I am trying to use MSHTML without the webbrowser and I am having a few problems. Right now all I am trying to do is load an URL(html page) and access its innerhtml. What I have is: Dim doc As...
11
2963
by: Bob Hollness | last post by:
Hi all (me again. I do try to answer the posts I can instead of just asking!!!) Any ideas how I could load a webpage into a control that was about the size of a stamp? I tried a few things but...
0
435
by: Vibhu Bansal | last post by:
Hello, I am having certain problems in trying to use the function createDocumentFromUrl in VB.NET but get this error.."Object reference not set to an instance of object". Here is the code that I...
0
2221
by: Atara | last post by:
Our application was build with VS 2003. I have tried to run it on a computer with .Net 2.0 (but without .Net 1.1 , as it should be used) and I got the following error - ...
0
7224
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
1
7039
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7494
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5050
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3192
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1553
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
415
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.