Open PrameetS opened 7 years ago
Any updates on this? same problem thanks.
No Updates, let me know if u get anything
Is this fixed? I still have the same issue on EPPlus Version 4.5.3.2. It drops an A on ttribute VB_Name = This Workbook". I.e. the code is corrupt after the copy.
Hello EPPLUS team,
I am having an issue while copying a ExcelWorkSheet and the corresponding CodeModule of the copied sheet in 4.1 EPPLUS version.
I have an excel file with macro's (.xlsm) and I use this excel file as a template to create another excel file.
I open the excel template (.xlsm) file and fetch some data from a database which needs to be written in new file.
Some time I need to copy a worksheet in template file, this is where the 'WorkSheets.Add()' comes in.
var newSheet = workbook.Worksheets.Add("someName", templateSheet);
After copying the template sheet and writing data on it, I am experiencing problems with VBA code. When I try to open the new excel file, it gives me below error.
The Visual Basic for applications (VBA) macros in this workbook are corrupted and have been deleted. The macro corruption most likely exists in the current file.
Below is the code from 'WorkSheets.Add("someName", templateSheet)' method: `//Copy the VBA code
if !MONO
endif`
I am not able to understand why in the last line epplus is changing the code module name of template sheet instead of newly added sheet?
Copy.CodeModuleName = name;
Is this a bug which causes the VBA code to be corrupted?
Also, when trying to change the code module name through below code
templateSheet.CodeModule.Name = "oldName";
causes templateSheet.CodeModule set to null.
Please look into it and resolve it.
Thanks, Prameet