08-11-2011 05:40 AM
Hello, I have made a lot of efforts to create and print an HTML Report.
I have concluded to the fact that it has to be printed via ActiveX.
But it is not working always. Some times the JPEG file that has to be printed, is not found and a "red X" is printed on the top-left of the page.
Other times it is printed successfully.
I attach an image of my code in which I use the ActiveX.
Is there something that I can do?
Thank you.
08-11-2011 08:16 AM
My guess is that the page hasn't fully loaded. The Navigate method will return before the page has loaded, so you can get to the next node before the picture has actually loaded. Try putting in a delay. If that works then that's the reason. Of course, the delay is just a band-aid. What you really want to do is to get a notification that the page has finished loading. You should be able to do this via an ActiveX callback. If you open the Example Finder (Help -> Find Examples) and search for "browser", you will find the VI "ActiveX Event Callback for IE", which shows you how to register for an ActiveX callback. You should be able to extend this to cover using a callback for when the page finishes loading.
08-11-2011 06:18 PM
I used the time delay but with no results.
Specifically i used the Wait function as shown below:
And the Elapsed Time function:
I could not understand how to use the Reg Event Callback:
08-12-2011 01:24 AM - edited 08-12-2011 01:25 AM
The way you've wired your Wait you'll always get False, same with Time has elapsed.
Only connect the 500 to wait (no wire around and compare) and put it in a flat sequence, wire the error through and remove the case.
500 mikght be way too low to load a web page btw, try with 5000 and 20000 also.
/Y
08-12-2011 10:22 AM
I tried what you said, but is still cannot work.
Here is what I tried:
I tried also to use the Reg Event Callback, but I cannot understand what I should connect to the VI Ref input, and how it will continue the program flow after the callback.
08-12-2011 10:57 AM
Hey nikosfs,
Due to how dataflow works in LabVIEW there is no guarantee in the code you have below that the wait will happen after your Web Browser function. To make sure that happens you need to add another framel to your flat sequence structure with the wait in the second frame or in the case of your second example you would need to add the frame with the wait before the IWebBrowser2 code.
As for the Event Callback the VI Ref is a VI which is called when the NavigateComplete Event happens. In this case you would want to put your second IWebBrowser2 invoke node into a SubVI and register that SubVI with the EventCallback.
Please post back if you have any additional questions.
08-16-2011 11:09 AM
I couln't solve the problem using the wait function. It waits but it still has the same problem.
What is more, I cannot find out how to connect the VI reference to the Event Callback.
I connected an output of this subvi (presented below) to the vi reference, in order to connect it to the VI reference input of the Event Callback, of the main VI file. But it gives an error saying "Wire: class conflict".
So, if the Event Callback is a trustworthy solution, how can I use it?
SubVI:
Here is the errror in the main VI:
08-16-2011 11:46 AM - edited 08-16-2011 11:46 AM
Did you look in the LabVIEW Help? http://zone.ni.com/reference/en-XX/help/371361G-01/lvhowto/reg_hndl_ax_evnts/
You right-click on that parameter and select Create Callback VI. This will automatically create a VI with the required inputs and outputs. This is the VI that will be called when the event occurs. If you need the callback VI to update any front panel controls of the main VI, then you can pass in control references via the User Parameter input.
Attached is a modification of the shipping example that handles the Navigate and DocumentComplete events.
08-16-2011 12:54 PM
I followed your instructions and here is what I have done:
Main VI:
VI Ref:
The result is that it never opens the dialog to print, as if the Document is never Completed.
What should I modify?
Thank you very much.
08-16-2011 12:58 PM
You're only showing part of the code. Please upload the actual VIs. This includes the callback VI as well.