Thanks for the reply, Mark. As time permits I will try your suggested approach and see if it works. I'll let you know what I find.
It's not critical for me to be able to do this; more of a 'nice-to-have' for what I need. Sincerely, Jon ________________________________ From: Mark Beardsley <[email protected]> To: [email protected] Sent: Fri, January 7, 2011 10:13:11 AM Subject: Re: Detecting the presence of VB/Macros in a workbook Hello Jon, Now, please bear in mind that I am speaking completely off of the top of my head and what I have to say may not make any real sense at all. Further, I have not had the oportunity to test this approach and do not know if it will wotk at all. Preamble out of the way, the initial answer to your question is no I think. POI is not able to do anything with macro or VBA code and always - at least as far as I am aware - simply preserves the relevant data structures it reads in the input stream in order to write them out again if required. The 'preserves the relevant data structures' bit above did set me thinking however and I do wonder if you would be able to iterate through the DirectoryNode/DirectoryEntry elements to detect if anything relating to macros had veen detected in the input stream. Speaking strictly about HSSF here, there is a method defined on the POIFSFileSystem class, called getRoot(), that will return a DirectoryNode object. On that is a method called getEntries() which will allow you to iterate over the various objects that together describe the Excel workbook I think. Whether one of these objects will contain the macro/vba related data structures, I do not know but it would be a very simple test to run. All you would need to do is; 1. Create an instance of the POIFSFileSystem class by passing an InputStream attached to the workbook to it's constructor. 2. Call the getRoot() method on the file system and catch the object this returns. 3. Call the getEntries() method on the object recovered in step 2 above. 4. Iterate through the Entry(s) and see what each one is. I cannot promise that will work but I do thibk the only course of action open to you is to simehow examine the file POI parses in order to determine whether any data structures related to macros/vba gave been detected. Yours Mark B -- View this message in context: http://apache-poi.1045710.n5.nabble.com/Detecting-the-presence-of-VB-Macros-in-a-workbook-tp3331147p3332166.html Sent from the POI - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
