Cannot save .xlsm file

Nov 4, 2016 at 12:53 PM
Edited Nov 4, 2016 at 12:55 PM
I have a file template (.xlsm) what has macro. I would like to create an excel file using the template. For some reason, I got error (Object reference not set to an instance of an object. ) when trying to save
Here is the code
           HttpContext context = HttpContext.Current;
           FileInfo template = new FileInfo("C:\\test\\EXAMPLE.xlsm");
            MemoryStream ms = new MemoryStream();
            using (ExcelPackage pack = new ExcelPackage(template, true))
                ExcelWorksheet ws = pack.Workbook.Worksheets.Add("SampleTab");  //line1
                ws.Drawings.AddShape("VBASampleRect", eShapeStyle.RoundRect);   //line 2
The error occurs at pack.SaveAs(ms);
If I comment out line1 and line2, it works fine.

Thanks in advance,