VbaProject Class |
The VbaProject type exposes the following members.
Name | Description | |
---|---|---|
![]() ![]() | VbaProject |
Creates a blank VbaProject.
|
Name | Description | |
---|---|---|
![]() ![]() | CodePage |
Returns the VBA project’s code page.
|
![]() ![]() | IsSigned |
Shows whether the VbaProject is signed or not.
|
![]() ![]() | Modules |
Returns collection of VBA project modules.
|
![]() ![]() | Name |
Gets or sets VBA project name.
|
![]() | References |
Gets a collection of VBA project references.
|
Name | Description | |
---|---|---|
![]() ![]() | Clone |
Performs a copy of the VbaProject.
|
![]() | Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) |
![]() | GetHashCode | Serves as the default hash function. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
Document doc = new Document(MyDir + "VBA project.docm"); // A VBA project contains a collection of VBA modules. VbaProject vbaProject = doc.VbaProject; Console.WriteLine(vbaProject.IsSigned ? $"Project name: {vbaProject.Name} signed; Project code page: {vbaProject.CodePage}; Modules count: {vbaProject.Modules.Count()}\n" : $"Project name: {vbaProject.Name} not signed; Project code page: {vbaProject.CodePage}; Modules count: {vbaProject.Modules.Count()}\n"); VbaModuleCollection vbaModules = doc.VbaProject.Modules; Assert.AreEqual(vbaModules.Count(), 3); foreach (VbaModule module in vbaModules) Console.WriteLine($"Module name: {module.Name};\nModule code:\n{module.SourceCode}\n"); // Set new source code for VBA module. You can access VBA modules in the collection either by index or by name. vbaModules[0].SourceCode = "Your VBA code..."; vbaModules["Module1"].SourceCode = "Your VBA code..."; // Remove a module from the collection. vbaModules.Remove(vbaModules[2]);