LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to use IHTMLFramesCollection2 to get elements in each frame?

In a project, I must visit elements value from HTML page, read or write. but there is a message 'error -2147467262 occurred at property node (arg1) in DocumentObjectMode.vi'. take the attached file for example, when I read the length of IHTMLFramesCollection2, the error shows. How it could be?

David Xia
Download All
0 Kudos
Message 1 of 8
(3,170 Views)

@adfsafsdfsad wrote:

In a project, I must visit elements value from HTML page, read or write. but there is a message 'error -2147467262 occurred at property node (arg1) in DocumentObjectMode.vi'. take the attached file for example, when I read the length of IHTMLFramesCollection2, the error shows. How it could be?


Why are you using LabVIEW for what is essentially a website project?  Microsoft's Visual Studio Express Basic would be a better tool for your needs.

0 Kudos
Message 2 of 8
(3,161 Views)

adfsafsdfsad,

 

In order to better assist you, could you give me a little more information on what it is you are trying to do with this FrameTest VI? Also, are you aware if this sequence you are programming with LabVIEW works in another programming language?

 

Thanks,

Jason M.
Applications Engineer
National Instruments
0 Kudos
Message 3 of 8
(3,150 Views)

Hi, NYC,

The main part of this project is programming in LabView,  so I don't want to change to another programming tool if LabView could implement it. it would save a lot of time.

David Xia
0 Kudos
Message 4 of 8
(3,145 Views)

adfsafsdfsad,

 

In order to better assist you, could you give me a little more information on what it is you are trying to do with this FrameTest VI? Also, are you aware if this sequence you are programming with LabVIEW works in another programming language?

 

Thanks,

Jason M.
Applications Engineer
National Instruments

 

Hi, Jason M.

The FrameTestVI is just for checking if the HTML Frames Collection works, My purpose is to find a solution to visit the elements in a frame with LabView.

David Xia
0 Kudos
Message 5 of 8
(3,144 Views)

adfsafsdfsad,

 

Since the error is being thrown after the IHTMLDocument2 property node executes, it seems that the variant data coming out of the Document selection of the IWebBrowser property node is not information you are looking for. It seems like this is the wrong reference for the IHTMLDocument2 property node. I suggest trying to determine what the appropriate reference is for that ActiveX node is and ensuring you can provide it from inside the while loop.

 

Best,

Jason M.
Applications Engineer
National Instruments
0 Kudos
Message 6 of 8
(3,134 Views)
Jason,

There must be something wrong, but the IHTMLDocument2 reference is correct, just some elements in IHTMLDocument2 property node didn't work properly, like the reference frames collection 2, there are two frames in the HTML page, but why the error occurs when I try to read the length of this collecion?

Thanks for your kindly help, Do you have any other useful suggestions?

David Xia
0 Kudos
Message 7 of 8
(3,125 Views)

Try running your code in the User Interface execution subsystem (VI Properties - Execution).  That eliminates the error for me (Win XP, LabVIEW 2011).

 

I'm not certain this is uniquely LabVIEW behavior.  Try running a Google search for "ihtmldocument2 frames property invalidcastexception" and you'll see that people using other languages appear to be having the same problem.  Several of the threads in those results say they were able to solve it by forcing everything to run in one thread, which is essentially what you're doing by changing to the user interface execution system.

 

One style note: you should close ALL ActiveX references that you open (the WebBrowser, Document, and IHTMLFramesCollection objects), in the opposite order in which you open them.  Also, I find it cleaner to use constants instead of controls for the ActiveX types (such as the type input to Variant to Data).

0 Kudos
Message 8 of 8
(3,101 Views)