Read Excel Macros Programmaticly in PHP or JS or Another Language

0

How to extract macros in Excel file in PHP or JS?

I found https://github.com/PHPOffice/PHPExcel/ but there is nothing about macros.

Digerkam

Posted 2017-03-15T08:34:59.467

Reputation: 123

Answers

1

With PHPExcel you can read the file and get the VBAProject.bin:

/**
* macrosCode : all macros code (the vbaProject.bin file, this include form, code,  etc.), null if no macro
*
* @var binary
*/
private $macrosCode;

You'd need other tools to examine the contents of the VbaProject.bin file.

E.g. using officeparser.py:

python officeparser.py macro.xlsm --extract-macros
INFO: Saving VBA code to ./ThisWorkbook.cls
INFO: Saving VBA code to ./Sheet1.cls
INFO: Saving VBA code to ./Sheet2.cls
INFO: Saving VBA code to ./Sheet3.cls

simlev

Posted 2017-03-15T08:34:59.467

Reputation: 3 184