Skip to content

Instantly share code, notes, and snippets.

@kjlubick
Created February 9, 2015 17:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kjlubick/5ead9ecf1c65a59470a2 to your computer and use it in GitHub Desktop.
Save kjlubick/5ead9ecf1c65a59470a2 to your computer and use it in GitHub Desktop.
Platform independent way to detect if an xls file has a macro using apache poi
//see http://www.rgagnon.com/javadetails/java-detect-if-xls-excel-file-contains-a-macro.html
public void processPOIFSReaderEvent(POIFSReaderEvent event) {
POIFSDocumentPath path = event.getPath();
if (path.length() == 0) {
return;
}
String firstFolder = path.getComponent(0);
if(firstFolder.startsWith("Macro") || firstFolder.startsWith("_VBA")) {
macroDetected = true;
}
}
@suju92
Copy link

suju92 commented Oct 8, 2020

Is there any way to detect macro in .doc file ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment