LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Writing to report (.doc) from different vi

Solved!
Go to solution

Hi,

 

I am using the report generation toolkit and I can generate the report (.doc).

I want to be able to append to the same .doc, but the .doc will be replaced when I run another vi to write to the .doc.

Both vi have the similar part:

JialingJade_0-1644402100092.png

 

JialingJade_1-1644402137059.png

 

How can I append to .doc if it already exists?

0 Kudos
Message 1 of 8
(1,767 Views)

Hello,

 

In your pictures you are creating two documents that fortunately have the the same and then are remplacing each other.

To write in the same one you will need to open a template with the good path at your "create report" function.

0 Kudos
Message 2 of 8
(1,762 Views)

Thanks for your reply!

0 Kudos
Message 3 of 8
(1,724 Views)

I still do not understand the process.

If I create a report with template as follows in one vi, and write to it.

How the second vi write to the same report?

1. It create a report again and write to it?

or

2. It need to get the "report out" created by the first vi?

JialingJade_0-1644475675270.png

 

If it needs to get the "report out" created by the first vi, how to transfer it from the first vi to the second vi?

By global variable?

 

I assume the "save to file" can only be used once after all data have been written.

 

0 Kudos
Message 4 of 8
(1,716 Views)

When using a template the file must at least already existing even if empty. Then it depends of your dataflow.

- If both your actions have to be able to write at the same time, then you need to share the "report out" between your sub-action / sub -vi. Create your report well before and then distribute the "report out" value to your sub-vi by a wire, cluster, etc... Beware race conditions.

- If your actions are writing at a specific moment ==> you can open the template, add some data, save and close the report then repeat elsewhere. If you file as a new filename, just use that new filename as template for the next "Create report".

0 Kudos
Message 5 of 8
(1,707 Views)

Thanks for your reply.

 

The two vis will not write to the report at the same. They are sequential.

The template is not empty, it also has some bookmarks.

 

"- If your actions are writing at a specific moment ==> you can open the template, add some data, save and close the report then repeat elsewhere. If you file as a new filename, just use that new filename as template for the next "Create report"."

 

I understand your process:

In the first vi:  create vi -> write data -> close the report.

In the second vi:  create vi -> write some other data -> close the report.

At last "save the report to file".

 

How to close the report?

In the second vi, create vi using the same template, the report will be the same report as the first vi?

Finally, all data inserted from the first vi and the second vi should be in the same .doc file.

 

 

0 Kudos
Message 6 of 8
(1,698 Views)
Solution
Accepted by topic author JialingJade

The process is always : create vi -> write data -> save =>close the report.

If not saving your data are lost at the closing action.

 

The close report function is that one and below an example.

Defaphe_0-1644480174564.png

path.png

 

0 Kudos
Message 7 of 8
(1,693 Views)

Thank you very much!

Your example vi is very useful!

Now I know the trick is: 

The first vi save to a .doc file, the second vi use the .doc file as a template!

 

0 Kudos
Message 8 of 8
(1,682 Views)