Class VbaModuleCollection

VbaModuleCollection class

Represents the list of VbaModule

public class VbaModuleCollection : CollectionBase<VbaModule>

Properties

NameDescription
Capacity { get; set; }
Count { get; }
Item { get; }Gets VbaModule in the list by the index. (2 indexers)
Item { get; set; }

Methods

NameDescription
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


[C#]

//Instantiating a Workbook object
Workbook workbook = new Workbook();
 // Init VBA project.
VbaProject vbaProject = workbook.VbaProject; 
// Add a new module.
vbaProject.Modules.Add(VbaModuleType.Class, "test");
//Saving the Excel file
workbook.Save("book1.xlsm");

 [Visual Basic]

'Instantiating a Workbook object
Dim workbook As Workbook = New Workbook()
'Init VBA project.
Dim vbaProject as VbaProject  = workbook.VbaProject
'Add a new module.
vbaProject.Modules.Add(VbaModuleType.Class, "test")
'Saving the Excel file
workbook.Save("book1.xlsm")

See Also