Lire les informations VBA du fichier MPP
Aspose.Tasks pour l’API .NET fournit une prise en charge de la lecture des informations VBA du fichier MPP. Cela comprend travailler avec:
Informations VBA.
Informations sur les modules contenus dans le projet.
Références Informations stockées dans le projet.
The following example shows how to read VBA Project Information with the help of VbaProject and Project class.
The following example shows how to read VBA References Information from VBA with the help of VbaProject, Project and VbaReference class
1Project project = new Project("New Project.mpp");
2
3VbaProject vbaProject = project.VbaProject;
4VbaReferenceCollection references = vbaProject.References;
5Console.WriteLine("Reference count ", references.Count);
6
7VbaReference reference = vbaProject.References.ToList()[0];
8Console.WriteLine("Identifier: " + reference.LibIdentifier);
9Console.WriteLine("Name: " + reference.Name);
10
11reference = vbaProject.References.ToList()[1];
12Console.WriteLine("Identifier: " + reference.LibIdentifier);
13Console.WriteLine("Name: " + reference.Name);
14
15reference = vbaProject.References.ToList()[2];
16Console.WriteLine("Identifier: " + reference.LibIdentifier);
17Console.WriteLine("Name: " + reference.Name);
Reading Modules Information from VBA
The following example shows how to read modules information from VBA with the help of VbaProject, Project and IVbaModule class
1Project project = new Project("New Project.mpp");
2
3VbaProject vbaProject = project.VbaProject;
4Console.WriteLine("Total Modules Count: " + vbaProject.Modules.Count);
5
6IVbaModule vbaModule = vbaProject.Modules.ToList()[0];
7Console.WriteLine("Module Name: " + vbaModule.Name);
8Console.WriteLine("Source Code: " + vbaModule.SourceCode);
Reading Module Attributes Information from VBA
The following example shows how to read modules attributes from VBA with the help of VbaProject, Project and IVbaModule class
1Project project = new Project("New Project.mpp");
2VbaProject vbaProject = project.VbaProject;
3IVbaModule vbaModule = vbaProject.Modules.ToList()[0];
4
5Console.WriteLine("Attributes Count: " + vbaModule.Attributes.Count);
6Console.WriteLine("VB_Name: " + vbaModule.Attributes.ToList()[0].Key);
7Console.WriteLine("Module1: " + vbaModule.Attributes.ToList()[0].Value);