Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merging Word documents in Ruby

I have N Word documents (Office 2003) from which I want to make a single Word document by merging all the N documents together in some order. How do I go about doing this in Ruby? Thanks!

It's just the documents that are created in MS Office. I do not use Windows and would prefer non-Windows solutions.

EDIT: Will this be easy if the docs are odt files rather than doc files?

like image 806
Vijay Dev Avatar asked Jul 16 '10 20:07

Vijay Dev


2 Answers

The only non-Windows solution that I know of is Ruby bindings in POI. After that, the code would be really similar to to this .NET code: Merge Word Documents As Pages Of A Single Document Using VB.NET. The key code you'll want is to use Selection.InsertFile for as many doucments as you need in the order you choose.

For ODT document merges, see this thread: http://cpanforum.com/threads/9938

like image 121
Todd Main Avatar answered Nov 10 '22 15:11

Todd Main


There is a whole series of really good articles about word and ruby at http://rubyonwindows.blogspot.com/search/label/word. Word files are really complicated, at least before 2007, so you're better off automating word to do it.

like image 28
stimms Avatar answered Nov 10 '22 16:11

stimms