MPPSaveOptions.WriteVba
Contents
[
Hide
]MPPSaveOptions.WriteVba property
Gets or sets a value indicating whether to update existing VBA macros data in MPP file. Currently writing of VbaModule.SourceCode is supported.
public bool WriteVba { get; set; }
Examples
Shows how to add/delete VBA macros to/from the existing VbaProject in MPP file.
var project = new Project(DataDir + "VbaProject.mpp");
var newModule = VbaModule.CreateProceduralModule("Module20");
newModule.SourceCode = @"Sub TestMacro()
#If conUnicode Then
Dim p As Project
Set p = Application.ActiveProject
MsgBox ""This is a message from a new macro. Current project: "" & p.Name
#End If
End Sub
Private Sub Project_BeforePrint(ByVal pj As Project)
End Sub";
project.VbaProject.Modules.Add(newModule);
var moduleToDelete = project.VbaProject.Modules["EventCode"];
project.VbaProject.Modules.Remove(moduleToDelete);
project.Save(OutDir + "VbaProject.AddedModule.mpp", new MPPSaveOptions() { WriteVba = true });
See Also
- class MPPSaveOptions
- namespace Aspose.Tasks.Saving
- assembly Aspose.Tasks