VbaModuleClone Method

Performs a copy of the VbaModule.

Namespace:  Aspose.Words.Vba
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 21.11.0

ExpandedSyntax

public VbaModule Clone()

Return Value

Type: VbaModule
The cloned VbaModule.

ExpandedExamples

Shows how to deep clone a VBA project and module.
Document doc = new Document(MyDir + "VBA project.docm");
Document destDoc = new Document();

VbaProject copyVbaProject = doc.VbaProject.Clone();
destDoc.VbaProject = copyVbaProject;

// In the destination document, we already have a module named "Module1"
// because we cloned it along with the project. We will need to remove the module.
VbaModule oldVbaModule = destDoc.VbaProject.Modules["Module1"];
VbaModule copyVbaModule = doc.VbaProject.Modules["Module1"].Clone();
destDoc.VbaProject.Modules.Remove(oldVbaModule);
destDoc.VbaProject.Modules.Add(copyVbaModule);

destDoc.Save(ArtifactsDir + "VbaProject.CloneVbaProject.docm");

ExpandedSee Also