Class VbaModuleCollection
Contents
[
Hide
]VbaModuleCollection class
Represents the list of VbaModule
public class VbaModuleCollection : CollectionBase<VbaModule>
Properties
Name | Description |
---|---|
Capacity { get; set; } | |
Count { get; } | |
Item { get; } | Gets VbaModule in the list by the index. (2 indexers) |
Item { get; set; } |
Methods
Name | Description |
---|---|
Add(Worksheet) | Adds module for a worksheet. |
Add(VbaModuleType, string) | Adds module. |
AddDesignerStorage(string, byte[]) | |
AddUserForm(string, string, byte[]) | Inser user form into VBA Project. |
BinarySearch(VbaModule) | |
BinarySearch(VbaModule, IComparer<VbaModule>) | |
BinarySearch(int, int, VbaModule, IComparer<VbaModule>) | |
Clear() | |
Contains(VbaModule) | |
CopyTo(VbaModule[]) | |
CopyTo(VbaModule[], int) | |
CopyTo(int, VbaModule[], int, int) | |
Exists(Predicate<VbaModule>) | |
Find(Predicate<VbaModule>) | |
FindAll(Predicate<VbaModule>) | |
FindIndex(Predicate<VbaModule>) | |
FindIndex(int, Predicate<VbaModule>) | |
FindIndex(int, int, Predicate<VbaModule>) | |
FindLast(Predicate<VbaModule>) | |
FindLastIndex(Predicate<VbaModule>) | |
FindLastIndex(int, Predicate<VbaModule>) | |
FindLastIndex(int, int, Predicate<VbaModule>) | |
GetDesignerStorage(string) | Represents the data of Designer. |
GetEnumerator() | |
IndexOf(VbaModule) | |
IndexOf(VbaModule, int) | |
IndexOf(VbaModule, int, int) | |
LastIndexOf(VbaModule) | |
LastIndexOf(VbaModule, int) | |
LastIndexOf(VbaModule, int, int) | |
Remove(string) | Remove the module by the name |
Remove(Worksheet) | Removes module for a worksheet. |
RemoveAt(int) |
Examples
using System;
using Aspose.Cells;
using Aspose.Cells.Vba;
namespace AsposeCellsExamples
{
public class VbaClassVbaModuleCollectionDemo
{
public static void Run()
{
// Create a new workbook
Workbook workbook = new Workbook();
// Access the VBA project
VbaProject vbaProject = workbook.VbaProject;
// Add a new class module
int index = vbaProject.Modules.Add(VbaModuleType.Class, "TestClass");
// Get the added module and add some code
VbaModule module = vbaProject.Modules[index];
module.Codes = "Public Sub TestMethod()\r\n MsgBox \"Hello from VBA!\"\r\nEnd Sub";
// Save as macro-enabled workbook
workbook.Save("VbaModuleCollectionDemo.xlsm", SaveFormat.Xlsm);
}
}
}
See Also
- class CollectionBase<T>
- class VbaModule
- namespace Aspose.Cells.Vba
- assembly Aspose.Cells