In case you figure out how to extract VBA , you are very much welcome to contribute this code back to POI.
Yegor On Sat, Apr 28, 2012 at 11:56 AM, Andrey Yesyev <[email protected]> wrote: > Yes, you're right. It compressed with LZW algorthm ( > http://en.wikipedia.org/wiki/LZW ). But according the spec, not all the > module, but only source code part. > Well, gonna dig deeper. > Thanks for reply! > > On 28 April 2012 10:51, Yegor Kozlov-4 [via Apache POI] < > [email protected]> wrote: > >> All I can suggest is to study the spec and write a decoder of VBA. I >> recall that macro code is compressed but it is not PKZIP but some >> other compression algorithm. >> >> If it is so, try to decompress your files first. >> >> I can't tell you exactly what to do - extracting VBA code is a big >> task and potentially can take days or weeks of work. >> >> Cheers, >> Yegor >> >> On Sat, Apr 28, 2012 at 11:32 AM, Andrey Yesyev <[hidden >> email]<http://user/SendEmail.jtp?type=node&node=5672237&i=0>> >> wrote: >> >> > Hey guys! >> > >> > I'm working on the same issue, getting macros code from XLS file. >> > I got VBA modules raw data htis way >> > >> > HSSFWorkbook wb = new HSSFWorkbook(is); >> > >> > ExcelExtractor extractor = new >> ExcelExtractor(wb); >> > >> > List<HSSFObjectData> l = >> wb.getAllEmbeddedObjects(); >> > DirectoryEntry root = extractor.getRoot(); >> > for(Entry entry:root){ >> > if(entry.isDirectoryEntry()){ >> > DirectoryEntry dirEntry = >> (DirectoryEntry)entry; >> > if(dirEntry.hasEntry("VBA")){ >> > DirectoryNode node = >> (DirectoryNode) dirEntry.getEntry("VBA"); >> > for(Entry e:node){ >> > DocumentNode >> docNode = (DocumentNode)e; >> > >> if(!docNode.getName().startsWith("dir") && >> > >> !docNode.getName().startsWith("_VBA_PROJECT") && >> > >> !docNode.getName().startsWith("__SRP")){ >> > >> System.out.println(docNode.getName()); >> > >> DocumentInputStream dis = new DocumentInputStream(docNode); >> > byte[] >> data = IOUtils.toByteArray(dis); >> > >> FileOutputStream fos = new >> > FileOutputStream("C:/"+docNode.getName()+"_data.txt"); >> > >> fos.write(data); >> > >> fos.close(); >> > } >> > } >> > } >> > } >> > } >> > >> > So I had 4 files. Sheet1_data.txt upto Sheet3_data.txt and >> > ThisWorkbook_data.txt. >> > My macros is in the ThisWorkbook_data.txt. But the problem is that I >> don't >> > recognize the format of these files as format of VBA module, described >> in >> > [MS-OVBA].pdf. >> > >> > Any ideas? >> > >> > -- >> > View this message in context: >> http://apache-poi.1045710.n5.nabble.com/DO-NOT-REPLY-Bug-52949-New-How-to-extract-VBA-Macros-code-from-Excel-file-by-using-POI-tp5579175p5672215.html >> > Sent from the POI - Dev mailing list archive at Nabble.com. >> > >> > --------------------------------------------------------------------- >> > To unsubscribe, e-mail: [hidden >> > email]<http://user/SendEmail.jtp?type=node&node=5672237&i=1> >> > For additional commands, e-mail: [hidden >> > email]<http://user/SendEmail.jtp?type=node&node=5672237&i=2> >> > >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [hidden >> email]<http://user/SendEmail.jtp?type=node&node=5672237&i=3> >> For additional commands, e-mail: [hidden >> email]<http://user/SendEmail.jtp?type=node&node=5672237&i=4> >> >> >> >> ------------------------------ >> If you reply to this email, your message will be added to the discussion >> below: >> >> http://apache-poi.1045710.n5.nabble.com/DO-NOT-REPLY-Bug-52949-New-How-to-extract-VBA-Macros-code-from-Excel-file-by-using-POI-tp5579175p5672237.html >> To unsubscribe from DO NOT REPLY [Bug 52949] New: How to extract VBA >> Macros code from Excel file by using POI?, click >> here<http://apache-poi.1045710.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5579175&code=YW5kcmV5Lnllc3lldkBnbWFpbC5jb218NTU3OTE3NXwyNDA3NTQzMw==> >> . >> NAML<http://apache-poi.1045710.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml> >> > > > -- > View this message in context: > http://apache-poi.1045710.n5.nabble.com/DO-NOT-REPLY-Bug-52949-New-How-to-extract-VBA-Macros-code-from-Excel-file-by-using-POI-tp5579175p5672244.html > Sent from the POI - Dev mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
