0

I would like some help to add a macro in an .xlsx file. I know that's not a good type of file, it should be an .xlsm file, but I have found Excel::Writer::XLSX in Perl that can add a macro to a new .xlsx file.

I want to open an existing .xlsx file (maybe with Excel::Reader::XLSX) and add vbaProject.bin into this file and save it (maybe as .xlsm). It has a function "add_vba_project()" but on Excel::Writer::XLSX which can't open existing file.

Has anyone found a solution in Perl or Python or PHP (PHPExcel for example) with or without vbaProject.bin?

pnuts
  • 58,317
  • 11
  • 87
  • 139
  • Note that it's `perl` not `pearl` – Mark Baker May 26 '14 at 11:58
  • When doing this natively in VBA, it requires the Visual Basic Extensibility 5.3 library. [This answer](http://stackoverflow.com/a/23738721/3198973) might be relevant if you need to use that library. – RubberDuck May 26 '14 at 12:31

1 Answers1

0

I don't believe you'll find a pure PHP library capable of this, even PHPExcel doesn't support macros; but you can do so using COM with MS Excel, PUNO with Open/Libre Office, or Ilia's extension for the commercial libXL library

Mark Baker
  • 209,507
  • 32
  • 346
  • 385