Inserting a new sheet in middle of the existing sheets of the workbook and trying to add a module for that sheet in vba project. it is removing other sheet vba code
workbook.Worksheets.Insert((int)sheetIndex, SheetType.Worksheet, p)
workbook[p].CodeName = “template2”;
workbook.VbaProject.Modules.Add(workbook.Worksheets[p]);
workbook.VbaProject.Modules[workbook.Worksheets[p].CodeName]
.Codes = vbCode;