This project is read-only.

What about macros?

Aug 20, 2009 at 4:10 PM

Since there is no documentation one can refer to, let me ask the author whether NPOI supports Excel files with macros?

Probably I did something wrong, but each time I try to open such a file, fill it with data and save it via NPOI, the resulting file gets corrupted. Excel opens it but is unable to save. Once macros are eliminated, everything goes smooth. Could you please tell me where the problem is?

Thank you.

Aug 21, 2009 at 3:12 PM

This should be a bug of the current version. I'll fix it in the next release.

Aug 21, 2009 at 3:13 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Sep 28, 2010 at 11:46 PM

Hi tonyqus

We have tried the NPOI and find the same problem with support of macros (vba code). The resulting files are corrupted, unable to save.

Is there already a solution?


Sep 29, 2010 at 2:45 AM

I feel sorry that this bug is not fixed in NPOI 1.2.3 because the VBA snippet is hard to be kept untouched. I'll continue research it when I'm free. I suggest you put the macro in another file and then reference the data in the current xls. Let me know if you have any concern.

Sep 30, 2010 at 12:52 PM

Hi borad, HiTom,

download the source, add the the newest 2 fixes at
from Greg (Compare-Method) and me (Clone-Method) in the code and compile your own DLL.

Tony wants to do it correctly and check the deeper problem,
however both fixes seem to be a solution for most cases, as they try to ensure the correct order of the VBA streams when written back in the stream and also enable internal copying of Macrocode, which is part of the problem.

Best regards