LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

combining n number of word files in a folder

is it possible to combine n number of word files in a folder to a single word file? 

If possible please let me know how to do it.

0 Kudos
Message 1 of 10
(1,130 Views)

Is it possible to make a labview code that can combine all word files in a folder to a single file

0 Kudos
Message 2 of 10
(1,122 Views)

Hi samkjacob,

 

Have you tried the code provided in this thread?

https://forums.ni.com/t5/LabVIEW/How-do-I-combine-two-word-files/m-p/197421#M113380

If yes, what is not working as expected?

 

PS: You initially posted the same question at 2 different places, which required a forum administrator to move your first post.

Please do not make duplicate posts, as it mobilizes twice the energy for no additional result.

 

Regards,

Raphaël.

Message 3 of 10
(1,114 Views)

There is no in built function/option to Append multiples file contents in a single file.

 

You can access the files and read the content and write to a single file one after the other.

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 4 of 10
(1,119 Views)

So can you help me with the code, is it possible to share an example code that can merge files from a particular folder to a single word file like as you mentioned earlier using write and read function.

 

I can combine two files or  more to a single word using report generation toolkit. But main aim is to access the folder and merge all the word files in it.

 

If you share the code it will be more helpful for me.

 

0 Kudos
Message 5 of 10
(982 Views)

So you have "word files", i.e. files in a very specific format defined by Microsoft and want to "combine" them (whatever that means). You probably need to be much more specific!

 

 Do you want to create a new word file with all content appended according to the alphabetical order of the file names? Something else? What if the output already exist in the same folder, how do you prevent an ever-growing output when the program is run again?  What should happen with metadata such as authors and comments? Are they really "MS word files" or something simple, such as "text" or "rich text"? Are the files just mostly text or do they have embedded pictures, tables, headers, footers, etc. What should happen with the original page numbers? What's the purpose of all this?

0 Kudos
Message 6 of 10
(968 Views)

I have 'n' number of word files (.docx format files) in a folder. My motive is to merge all the Word files from a particular folder to a single word document (.docx format). So basically i need a labview code where I can give a folder path as well as the output merged document file path where the code will merge all the .docx in the folder to a single word document file.

 

What if the output already exist in the same folder, how do you prevent an ever-growing output when the program is run again? 

The output of the merged document should be in different path.

 

What should happen with metadata such as authors and comments?

The word files in the folder is mainly generated using my another program, so no problem with that.

 

Are they really "MS word files" or something simple, such as "text" or "rich text"? Are the files just mostly text or do they have embedded pictures, tables, headers, footers, etc.

They are MS word file documents. They have tables in it. Each Ms Word file in the folder is one page only having a table.

 

What should happen with the original page numbers?

The files are in a sequence so no problem with that

0 Kudos
Message 7 of 10
(917 Views)

@samkjacob wrote:

I have 'n' number of word files (.docx format files) in a folder. My motive is to merge all the Word files from a particular folder to a single word document

...

They are MS word file documents. They have tables in it. Each Ms Word file in the folder is one page only having a table.

It is absolutely LabVIEW-related question. Obviously you can't simply append binary content of one Word doc to another, you should parse the structure.

Use pandoc to merge, this is probably an easiest way, something like

 

pandoc.exe File1.docx File2.docx -o FileMerged.docx

 

Of course, this tool can be called from LabVIEW via SystemExec

 

0 Kudos
Message 8 of 10
(878 Views)

A modern Microsoft Word file is a zip archive with lots of different files in a specific folder structure in it. Most of those files are in XML format including the text information itself. So it’s certainly possible to do what you want but not very trivial. Since, as Christian Altenbach has listed, there are many options about what to do in different situations there are almost certainly no ready made solutions.

 

There are likely four promising options in increasing order of complexity.

 

1) find a tool that does what you want and call it through SystemExec

 

2) did you look at the thread mentioned earlier? What is not good for you with that?

 

3) Using the Word .Net interface in LabVIEW try to replicate the functionality from the other thread already mentioned

 

4) Try to open the zip file that a docx file really is, understand its internet file structure and find the file that contains the document contents and then understand its XML schema and extract the according text part and combine it together, saving it correctly to the docx file back.

Rolf Kalbermatter
My Blog
Message 9 of 10
(876 Views)

What, no mention of the "LabVIEW Report Generation Toolkit for Microsoft Office"?
https://www.ni.com/pdf/manuals/repGenTK_2014readme_KB.html

 

---------------------------------------------
Certified LabVIEW Developer (CLD)
0 Kudos
Message 10 of 10
(853 Views)