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.That(doc.HasMacros, Is.True);
Assert.That(doc.VbaProject.Name, Is.EqualTo("Project"));

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

Assert.That(doc.HasMacros, Is.False);
Assert.That(doc.VbaProject, Is.Null);

See Also