LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Print PDF report in exe on other PC

Solved!
Go to solution

@bjoernde wrote:

@UliB

 

I´ve read that I have to insert the template to the "always included" when I build the exe, so I did this. 

Is it possible that it´s not enough to insert the template document only? Should I insert any folders where the template is in?

 

Error 7 says that the is a problem with the file. So it must be a wrong way I am inserting this template when buildingthe EXE?


It is correct to always includ the file. The question is: When the application is build, where is the file in the file system? I **think** if do not specify anything in 'Source File Setting' category, the file will be in the 'Support Directory' (see 'Destinations' category). You can define your own destination in 'Destinations' category and have to make the combination between file and destination in 'Source File Settings' category.

Besides these settings you always can go to 'Preview' category, 'Generate Preview' and check where the template will be put in the file system. Does the path of the file in the file system match with the path you use in the application?

Note: All categories I refer to are in the 'Build Specifications' for an Application (EXE).

0 Kudos
Message 11 of 14
(200 Views)

The Generate preview is a great tool! I didn´t notice it before.

 

So in the "Destinations" in the "Support directory" there was another path than in the exe above. I´ve changed it and know it looks like in the attached picture.

 

In the Preview before I changed this path the template was in a separate "data" folder. But now it´s directly in the same folder as the exe. Is this the match you said?

0 Kudos
Message 12 of 14
(197 Views)
Solution
Accepted by bjoernde

@bjoernde wrote:

The Generate preview is a great tool! I didn´t notice it before.

 

So in the "Destinations" in the "Support directory" there was another path than in the exe above. I´ve changed it and know it looks like in the attached picture.

 

In the Preview before I changed this path the template was in a separate "data" folder. But now it´s directly in the same folder as the exe. Is this the match you said?


Until now I was not able to look at your VI, but now I have access to LabVIEW2020 and see what you are doing.

Dave and I thought you would use the 'Report Generation Toolkit' and create a 'Word Report'. But you use the 'MS Office Report' Express VI. So our messages to 'ExportAsFixedFormat' were no help for you, sorry for that.

 

The 'Configure MS Office Report' Dialog defines an absolut 'Path To Template'. In your VI this is 'C:\Program Files (x86)\National Instruments\LabVIEW 2020\templates\Report\MSOffice_RGT_Template.dot'. This path is hard coded in the VI and can't be changed during execution.

The template has to exist in this path on every PC you want to run your application.

You now have put the template next to your application, so the path should be something like 'C:\Program Files (x86)\YourApplication\MSOffice_RGT_Template.dot'.

You could specify a path like 'c:\template\MSOffice_RGT_Template.dot' and use an installer build specification to install your application and the template in the specified path on every PC.

 

Hope this helps

0 Kudos
Message 13 of 14
(177 Views)

Sorry that I hadn't paid close attention to your original attachments.  I see that you started from an Express VI which does, in fact, wrap calls to VIs from the Report Generation Toolkit.

 

If you dig down into the call chain of your Express VI, after you've configured it and converted it into a regular VI, you will see that it calls subMS Office Report Block.vi; and inside that subVI's block diagram you finally get to see the dependencies on the RGT.  Somewhere in the case structure for the "Print to Printer" case handling, you could substitute the VI I provided you.  It will automate Word to save the in-memory document to one of the two supported "fixed formats".  It is, I believe, analogous to interactively operating Word through the File->Export menu.

 

Of course, if you do this, you should consider saving a copy of the subMS Office Report Block.vi you've modified into your own project hierarchy; you don't want to alter the library copy.  Also, you will need to specify the path to your output PDF file; you could use a constant, but more flexibly you'd add a parameter to the connector pane.

 

Solely my opinion here: Express VIs are perhaps ok for quickly mocking up some desired code, and seeing what can be accomplished with minimal coding effort (and how library VIs can be leveraged), but I can not recommend going far with them for a "real" project.  Take the bits and pieces you find, and make your own VIs for your project.

 

Good luck!

 

Dave

David Boyd
Sr. Test Engineer
Abbott Labs
(lapsed) Certified LabVIEW Developer
0 Kudos
Message 14 of 14
(169 Views)