![]() |
How to decide if an excel file has got VBA code in it ?
Guys,
I am looking for a way to decide whether an excel file has got some VBA code in it? How can i achieve this without opening the excel file and macros. I have a set of excel files in my organisation and need to filter all the excel files which has got some VBA code inside it. I am probably looking for creating a tool in c# to do this automation. So if anyone of you have any knowledge of c# classes to access office components like excel that will be helpful. Many Thanks in advance, -- SKP |
How to decide if an excel file has got VBA code in it ?
On Aug 4, 4:33*pm, Sujit wrote:
Guys, I am looking for a way to decide whether an excel file has got some VBA code in it? How can i achieve this without opening the excel file and macros. I have a set of excel files in my organisation and need to filter all the excel files which has got some VBA code inside it. I am probably looking for creating a tool in c# to do this automation. So if anyone of you have any knowledge of c# classes to access office components like excel that will be helpful. Many Thanks in advance, -- SKP This is the case: Every XLS file is in fact OLE2 Compound File/Document, also called " COM/OLE structured storage" (http://en.wikipedia.org/wiki/ Structured_storage). That file internally contains streams of data with various parts of XLS file. If there is a stream called "_VBA_PROJECT_CUR" inside XLS file, you can be sure it contains VBA code. In other words, open file as OLE2 Compound Document and check stream names for macro stream name. In C# you can open OLE2 Compound Documents using our GemBox.CompoundFile component (http:// www.gemboxsoftware.com/CompoundFile.htm, Free version is size limited). There you also have viewer for OLE2 Compound Files. For new XLSX file format, check is trivial. If the file contains macros, it has extension .XLSM. If you want to remove Macros from XLS file, you can use our GemBox.Spreadsheet Excel component (http://www.gemboxsoftware.com/ GBSpreadsheet.htm) and deselect Preserve when loading the file (http:// http://www.gemboxsoftware.com/help/G...sOptions.html). And, of course, you can use Excel Automation/interop, which has its drawbacks (http://www.gemboxsoftware.com/GBSpre...htm#Automation) but it supports ALL features of Excel file formats. Hope I helped, -- Zeljko |
All times are GMT +1. The time now is 10:27 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com