RemoveMacros

Document.RemoveMacros method

Removes all macros (the VBA project) as well as toolbars and command customizations from the document.

public void RemoveMacros()

Remarks

By removing all macros from a document you can ensure the document contains no macro viruses.

Examples

Shows how to remove all macros from a document.

Document doc = new Document(MyDir + "Macro.docm");

Assert.IsTrue(doc.HasMacros);
Assert.AreEqual("Project", doc.VbaProject.Name);

// Remove the document's VBA project, along with all its macros.
doc.RemoveMacros();

Assert.IsFalse(doc.HasMacros);
Assert.Null(doc.VbaProject);

See Also