Example Code

Append Table to Report with MS Word 2010

Code and Documents

Attachment

Overview
This example VI provides a workaround for this issue if it is used to replace the Append Table to Report VI.


Description
The example VI  provides a workaround for this issue if it is used to replace the Append Table to Report VI. This VI first checks if the report is a Word Report or any other type of report (the error is shown only in Word). If it is a Word Report, an empty table of the correct size is created and the values are entered individually at their corresponding location in the table. This will be slower than the Append Table to Report VI, because each cell is entered individually, but it should eliminate the incorrect behavior. Finally, the table will not be copied to the report and appear to be transduced with the value of every row repeated. See the images below for an example of the erroneous behavior.

Expected Behavior:

 .png

Incorrect Behavior:

  .png To use this VI, just directly replace the Append Table to Report VI on your Block Diagram. The VI is written in LabVIEW 2011. The LabVIEW 2010 version is also attached and titled "Word 2010-AppendTableToReport-LV201.vi".

 


Requirements

  • LabVIEW 2012 (or compatible)
  • LabVIEW 2012 Report Generation Toolkit for Microsoft Office (or compatible)


Steps to Implement or Execute Code

  1. Download the attached folder to your computer
  2. Open the VI " Word 2010 Append Table To Report 2012 NIVerified.vi"
  3. Input the controller named as "column width controller", "measurement system for column width ", "column headers", "row headers", "text data"
  4. Run the program

 

Additional Information or References
VI Snippet

 Block Diagram.PNG

 

**This document has been updated to meet the current required format for the NI Code Exchange.**

Matt
NI Community Team
National Instruments

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
MauricioAvalos
Member
Member
on

Por favor puedes subir, este VI en Labview 2010 Version

rhys
Member
Member
on

Nice fix worked as described.  Thanks for reporting and detailing.

OlderJohn
Member
Member
on

This VI helped me out with Labview 2010 SP1, but it does not account for column and/or row headers.

Snamprogetti
Active Participant
Active Participant
on

The problem is in "Word Insert Table.vi" (in _wordsub.llb). It transforms the 2D array data into a \n-separated string and pastes it into the table. Maybe this worked on previous Word versions, but normally the string should be tab-separated, with \n only at row ends. Fixing Word Insert Table is easy and better than a workaround. Hopefully NI will fix it, did anyone submit a bug report?

Matt_McLaughlin
NI Employee (retired)
on

Hi Snamprogetti,

I believe that the problem was caused by changes between versions of Word. I completely agree that a fix in the toolikit is better than a workaround and a Corrective Action Request has been submitted.

Matt
NI Community Team
National Instruments
Snamprogetti
Active Participant
Active Participant
on

For now, here is a simple way to fix "Word Insert Table.vi". I think i can't attach a VI here, but just follow the arrows and do it yourselfFix Word Insert Table.png

philmore
Member
Member
on

Thanks Snamprogetti

I was pulling my hair. Insert table worked using Word 2000 then stopped working when upgraded to Word 2010.

TKVO
Member
Member
on

Thanks All, for help Snamprogetti, but was partial success.

I spend lot of time to get tables correct

.

Environment:

LV 2011

MS Office : Word : 2016

 

Working Solution:

Update the highlighted Vi with simple Array to string without any demlimiter.

 

 

Array To Spreadsheet String

Converts an array of any dimension to a table in string form, containing tabs separating column elements, a platform-dependent EOL character separating rows, and, for arrays of three or more dimensions, headers separating pages.

 

TKVO_2-1644175547096.png