Nick Burch <nick <at> torchbox.com> writes:
>
> On Thu, 2 Aug 2007, Vladimir wrote:
> > I found the way to determine if an Excel document contains macro, but I
> > can't distinguish if that macro is password protected or visible to
> > everyone.
>
> Your best bet is to create a simple excel file, containing a few cells,
> and your macro (un-protected). Save a copy of that.
>
> Now, open up the copy, and password protect the macro. Save
>
> Finally, make use of the classes under org.apache.poi.hssf.dev (especially
> BiffViewer) to spot what's different. Once you know that, it ought to be
> fairly easy to spot the bit of POI that'll know, or at least the bit of
> POI that could know with a tiny patch :)
>
> Nick
>
Thank you for quick response.
I tried your idea:
BiffViewer.main(new String[]{
"C:\\Radni\\historianTest\\tmp\\in\\test03_with_macro_protected.xls"});
but document with macro and its copy with password protected macro, produced no
difference.
Any other idea?
Simplification of code which I use to detect macro:
...
POIFSReader r = new POIFSReader();
MacroListener macroL = new MacroListener();
r.registerListener(macroL);
FileInputStream fis = new FileInputStream(file);
r.read(fis);
...
private class MacroListener implements POIFSReaderListener {
boolean macroDetected = false;
public boolean isMacroDetected() {
return macroDetected;
}
public void processPOIFSReaderEvent(POIFSReaderEvent event) {
if(event.getPath().toString().startsWith("\\Macros") ||
event.getPath().toString().startsWith("\\_VBA")) {
macroDetected = true;
}
}
...
Beside Excel this code can be used to detect macros in other Office documents.
Is it possible to do some extension or variation of this code to detect
differences between macros without password protection and password protected
macros?
Any idea is welcome.
Vladimir
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]