0
votes

I have a word document (in .dot) format with recorded macros. I have java code that copies the entire content of the word document to another word document (another .dot format document).

But the newly created document is missed with the recorded macros. I need to copy the macros also, into the new document. How can I do that?

1

1 Answers

0
votes

If you are using Apache POI, then you can't copy macros the way you are doing it piece by piece using the library.

From the page "Apache POI - HSSF and XSSF Limitations"

Macros can not be created. The are currently no plans to support macros. However, reading and re-writing files containing macros will safely preserve the macros.

But what you can do is:

  1. Copy the whole file (just read it using a FileInputStream and write a copy using a FileOutputStream)
  2. Open the copy using Apache POI to do any manipulation to the document text that you like