Hi Martin,
Thanks for your inquiry.
For .doc/.docm file, you could use Spire.Doc and following code to delete Marcos.
- Code: Select all
//Initialize a Document object
Document document = new Document();
//Load the Word document
document.LoadFromFile("Input.docm");
//If the document contains macros, remove them from the document
if (document.IsContainMacro)
{
document.ClearMacros();
}
//Save the document
document.SaveToFile("Output.docm", FileFormat.Docm);
For .xls/.xlsm file, you could use Spire.XLS and following code:
- Code: Select all
Workbook workbook = new Workbook();
workbook.LoadFromFile(@"F:\testing\xls test form\sample document\Macro test.xls");
//clear the marcos
workbook.HasMacros = false;
workbook.SaveToFile("result.xlsx",ExcelVersion.Version2013);
For .ppt/.pptm file, sorry that at present there is no method to delete Marcos in Spire.Presentation. We will consider adding the new feature in our future upgrade.
Note if you want to use Spire.Doc, Spire.XLS and Spire.Presentation in same project, you need to download our
Spire.Office and reference corresponding dlls(Spire.License.dll, Spire.Doc.dll, Spire.Pdf.dll, Spire.Xls.dll, Spire.Common.dll, Spire.Presentation.dll) in your project.
And new feature will be included in commercial version firstly. We will let you know once the hotfix which includes the new feature is released.
Sincerely,
Betsy
E-iceblue support team