sheetjs/docbits/77_macrovba.md
SheetJS 825830d1cd version bump 0.11.7: VFP DBF write
- DBF writer (dBASE II + VFP extensions)
- updated CFB to 0.13.2
- BIFF8 XLS write VBA
2017-10-27 12:25:54 -04:00

1019 B

VBA and Macros

VBA Macros are stored in a special data blob that is exposed in the vbaraw property of the workbook object when the bookVBA option is true. They are supported in XLSM, XLSB, and BIFF8 XLS formats. The supported format writers automatically insert the data blobs if it is present in the workbook and associate with the worksheet names.

Macrosheets (click to show)

Older versions of Excel also supported a non-VBA "macrosheet" sheet type that stored automation commands. These are exposed in objects with the !type property set to "macro".

Detecting macros in workbooks (click to show)

The vbaraw field will only be set if macros are present, so testing is simple:

function wb_has_macro(wb/*:workbook*/)/*:boolean*/ {
	if(!!wb.vbaraw) return true;
	const sheets = wb.SheetNames.map((n) => wb.Sheets[n]);
	return sheets.some((ws) => !!ws && ws['!type']=='macro');
}