LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Print file via ActiveX,and it is not found always

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.

ActiveX print.JPG

Is there something that I can do?

Thank you.

0 Kudos
Message 1 of 21
(3,410 Views)

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.

0 Kudos
Message 2 of 21
(3,406 Views)

I used the time delay but with no results.

Specifically i used the Wait function as shown below:

Capture1.JPG

 

And the Elapsed Time function:

Capture2.JPG

 

I could not understand how to use the Reg Event Callback:

Capture3.JPG

0 Kudos
Message 3 of 21
(3,399 Views)

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

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 4 of 21
(3,393 Views)

I tried what you said, but is still cannot work.

Here is what I tried:

Capture4.JPG

 

Capture5.JPG

 

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.

Capture6.JPG

0 Kudos
Message 5 of 21
(3,378 Views)

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.

Kevin Fort
Principal Software Engineer
NI
0 Kudos
Message 6 of 21
(3,374 Views)

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:

Capture7.JPG

 

Here is the errror in the main VI:

 

Capture8.JPG

0 Kudos
Message 7 of 21
(3,341 Views)

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.

0 Kudos
Message 8 of 21
(3,337 Views)

I followed your instructions and here is what I have done:

 

Main VI:

 

Capture9.JPG

 

 

VI Ref:

Capture10.JPG

 

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.

0 Kudos
Message 9 of 21
(3,332 Views)

You're only showing part of the code. Please upload the actual VIs. This includes the callback VI as well.

0 Kudos
Message 10 of 21
(3,328 Views)