How to delete and insert VBA Macros from/to the document using .NET

Hi,
According this https://docs.aspose.com/words/net/insert-and-append-documents/
article I’ve inserted VBA form into destination document.
here is the code:

// Open the destination document.
Document dstDoc = new Document("macros.doc");
// Open the source document.
Document srcDoc = new Document(filePath);
// For a twist, let's say I want the second document to start on the same page where
// the first document ends. This is controlled by a property of the first section.
srcDoc.FirstSection.PageSetup.SectionStart = SectionStart.Continuous;
// Combine the documents, see the function below.
AppendDoc(dstDoc, srcDoc);
// Save the finished document.
dstDoc.FirstChild.Remove();
dstDoc.Save(filePath);

It works fine, but I have more questions :

  • How can I insert one more VBA module;\ - How can I delete inserted module, without using
dstDoc.RemoveMacros();

Thanks,
Valera

Hi

Thanks for your inquiry. There is no way to add macro programmatically using Aspose.Words. For deleting macros you can use just this method RemoveMacros().
Best regards,

@valery.lee

With the latest version of Aspose.Words for .NET 20.5, you can insert VBA macro into document. Please read the following article about working with VBA macros. .
Working with VBA Macros