We have a specific requirement where we need to remove few vba modules from vba project but when trying using aspose words we not able to remove the module from Vba. following is sample code for the same.
using (MemoryStream memoryStream = new MemoryStream(fileName, true))
{
Document _doc = new Document(memoryStream);
VbaProject vba = _doc.VbaProject.Clone();
//_doc.VbaProject = new VbaProject();
foreach (VbaModule vbaModule in vba.Modules)
{
if (vbaModule.Name.ToLower().Contains("custom"))
{
if (vbaModule.Type == VbaModuleType.ProceduralModule || vbaModule.Type == VbaModuleType.ClassModule)
{
VbaModule mod = _doc.VbaProject.Modules[vbaModule.Name];
_doc.VbaProject.Modules.Remove(mod);
}
}
}
}
Attached are the sample template and expected and actual response of the code when saved.
Sample-2.zip (41.1 KB)
Thanks