public static void extractMacros(POIFSFileSystem fs, ContentHandler xhtml,
                                     EmbeddedDocumentExtractor embeddedDocumentExtractor)
            throws IOException, SAXException {

        VBAMacroReader reader = null;
        Map<String, String> macros = null;
        try {
            reader = new VBAMacroReader(fs);
            macros = reader.readMacros();
        } catch (SecurityException e) {
            throw e;
        } catch (Exception e) {
            Metadata m = new Metadata();
            m.set(TikaCoreProperties.EMBEDDED_RESOURCE_TYPE,
                    TikaCoreProperties.EmbeddedResourceType.MACRO.toString());
            m.set(Metadata.CONTENT_TYPE, "text/x-vbasic");
            EmbeddedDocumentUtil.recordException(e, m);
            if (embeddedDocumentExtractor.shouldParseEmbedded(m)) {
                embeddedDocumentExtractor.parseEmbedded(
                        //pass in space character so that we don't trigger a zero-byte exception
                        TikaInputStream.get(new byte[]{'\u0020'}), xhtml, m, true);
            }
            return;
        }
        for (Map.Entry<String, String> e : macros.entrySet()) {
            Metadata m = new Metadata();
            m.set(TikaCoreProperties.EMBEDDED_RESOURCE_TYPE,
                    TikaCoreProperties.EmbeddedResourceType.MACRO.toString());
            m.set(Metadata.CONTENT_TYPE, "text/x-vbasic");
            if (!StringUtils.isBlank(e.getKey())) {
                m.set(TikaCoreProperties.RESOURCE_NAME_KEY, e.getKey());
            }
            if (embeddedDocumentExtractor.shouldParseEmbedded(m)) {
                try (TikaInputStream tis = TikaInputStream.get(e.getValue().getBytes(StandardCharsets.UTF_8))) {
                    embeddedDocumentExtractor.parseEmbedded(tis, xhtml, m, true);
                }
            }
        }
    }
Helper to extract macros from an NPOIFS/vbaProject.bin
<p>
As of POI-3.15-final, there are still some bugs in VBAMacroReader.
For now, we are swallowing NPE and other runtime exceptions

@param fs                        NPOIFS to extract from
@param xhtml                     SAX writer
@param embeddedDocumentExtractor extractor for embedded documents
@throws IOException  on IOException if it occurs during the extraction of the embedded doc
@throws SAXException on SAXException for writing to xhtml
tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-microsoft-module/src/main/java/org/apache/tika/parser/microsoft/OfficeParser.java