You will need to write a program to do so - or buy a control that already does somethng like that.
Aspose have controls that I think allow you to do this.
Also see
here
Or I suppose you could use Word automation - see
here[
^]
Or just use Google - that's what I just did.