Creating Excel file including VBA code

Topics: Developer Forum
Mar 12, 2009 at 8:12 AM
I see that ExcelPackage is capable of generating excel files from scratch with data and format. But can I also add macro VBA code to the excel file, so that the user has a set of working makros delivered with the data.
Thanks in advance, Steven.
Jan 10, 2011 at 8:05 PM

Steven did you even solve adding VBA code to an Excel via the ExcelPackage?

Jan 11, 2011 at 7:25 AM

Jim, unfortunately not. Actually I didn't find any open source package of being capable to do so.

The intended task I was looking for this, is to put database data to an excel file which includes macros for individual analysis. Now, we are using a workaround for this. We have a "clever" excel file on the server, which means that it contains macros, but no data. Upon the user request database data is dumped to a new csv. The user gets both these files via email. Because the email system puts both files to the same but arbitrary directory, the user can open the excel file and enable macros. At startup the excel file reads the csv data and imports everything. Result: Excel file with macros and data from an intranet site.

Jan 11, 2011 at 3:54 PM

Thank you Steven for the information.

Yea what I am trying to do is have a xlsx for use with the Office Excel web since xlsm cannot be used with the web version of Excel. This would allow standard Excel editing and features but of course no macros (VBA). If the user wants the more advance use of the Excel file then they would open it on their machine via the Excel web version button and via addins installed on their client the macro xml package would be inserted into the Opened excel file and converted from a xlsx into a xlsm. The Excel file on the server would contain a custom property that the client addin would use to indentify it so as to place the macro file into the OOXML package. Does this make sense to you?

Jan 11, 2011 at 4:08 PM

Sorry, I am out, because I am not very familiar with the office web versions and addins. Good luck!