There is a VBA project if I open the file and look but the following method is showing VbaProject as null.
```
using (ExcelPackage excelpack = new ExcelPackage(utfile))
{
if (excelpack.Workbook.VbaProject == null) throw new ApplicationException("Error on getting the project");
excelpack.Workbook.VbaProject.Protection.SetPassword("EncryptedLockCode");
excelpack.Save();
}
```
I've tried on both .xlsx and .xlsm.
```
using (ExcelPackage excelpack = new ExcelPackage(utfile))
{
if (excelpack.Workbook.VbaProject == null) throw new ApplicationException("Error on getting the project");
excelpack.Workbook.VbaProject.Protection.SetPassword("EncryptedLockCode");
excelpack.Save();
}
```
I've tried on both .xlsx and .xlsm.