VbaModuleCollection Class
Represents the collection of VbaModule.
public sealed class VbaModuleCollection : IEnumerable<VbaModule>, IEnumerable
Public NotInheritable Class VbaModuleCollection
Implements IEnumerable(Of VbaModule), IEnumerable
- Inheritance:
- System.ObjectVbaModuleCollection
Properties
Count
Gets the number of elements contained.
Property Value
- System.Int32
Item[ExcelWorksheet]
Gets the VbaModule that is bound to the given ExcelWorksheet.
public VbaModule this[ExcelWorksheet worksheet] { get; }
Public ReadOnly Property Item(worksheet As ExcelWorksheet) As VbaModule
Parameters
worksheet
- ExcelWorksheet
The ExcelWorksheet that has the VbaModule being bound.
Property Value
Item[Int32]
Gets the VbaModule at the specified index.
public VbaModule this[int index] { get; }
Public ReadOnly Property Item(index As Integer) As VbaModule
Parameters
index
- System.Int32
The zero-based index of the VbaModule to get.
Property Value
Item[String]
Gets the VbaModule with the given name.
public VbaModule this[string name] { get; }
Public ReadOnly Property Item(name As String) As VbaModule
Parameters
name
- System.String
Name of the VbaModule to get.
Property Value
Methods
Add(ExcelWorksheet)
Creates and returns a new VbaModule bound to the given ExcelWorksheet.
public VbaModule Add(ExcelWorksheet worksheet)
Public Function Add(worksheet As ExcelWorksheet) As VbaModule
Parameters
worksheet
- ExcelWorksheet
The worksheet to bind the module.
Returns
Add(ExcelWorksheet, String)
Creates and returns a new VbaModule with the given name and bound to the given ExcelWorksheet.
public VbaModule Add(ExcelWorksheet worksheet, string name)
Public Function Add(worksheet As ExcelWorksheet, name As String) As VbaModule
Parameters
worksheet
- ExcelWorksheet
The ExcelWorksheet to bind VbaModule.
name
- System.String
Name of the returning VbaModule.
Returns
Add(String)
Creates and returns a new VbaModule with the given name and with the type of Procedural.
Parameters
name
- System.String
Name of the returning VbaModule.
Returns
Add(String, VbaModuleType)
Creates and returns a new VbaModule with the given name and type.
If the given vbaModuleType
is Document, returning VbaModule will be bound to ExcelFile.
public VbaModule Add(string name, VbaModuleType vbaModuleType)
Public Function Add(name As String, vbaModuleType As VbaModuleType) As VbaModule
Parameters
name
- System.String
Name of the returning VbaModule.
vbaModuleType
- VbaModuleType
Type of the returning VbaModule.
Returns
AddCopy(VbaModule)
Clones and returns a new VbaModule from the given module.
public VbaModule AddCopy(VbaModule vbaModule)
Public Function AddCopy(vbaModule As VbaModule) As VbaModule
Parameters
Returns
VbaModule that is cloned and added to the collection.
If Type is Document and the corresponding ExcelWorksheet is not found and Code is null or empty returns null
Remarks
If Type is Document and the corresponding ExcelWorksheet is not found, then there are two possible operations.
If Code exists in the VbaModule then Type of the cloned VbaModule will be Procedural instead. Otherwise method will return null
Clear()
Removes all items from the collection.
Contains(ExcelWorksheet)
Indicates whether this collection contains the VbaModule object with the specified excelWorksheet
.
public bool Contains(ExcelWorksheet excelWorksheet)
Public Function Contains(excelWorksheet As ExcelWorksheet) As Boolean
Parameters
excelWorksheet
- ExcelWorksheet
The ExcelWorksheet that binds VbaModule.
Returns
- System.Boolean
true if the collection contains an item bound to the excelWorksheet
; otherwise, false.
Contains(String)
Indicates whether this collection contains the VbaModule object with the specified name
.
Parameters
name
- System.String
The name of the module to locate.
Returns
- System.Boolean
true if the collection contains an item with the name
; otherwise, false.
GetEnumerator()
Returns an enumerator that iterates through the collection.
public IEnumerator<VbaModule> GetEnumerator()
Public Function GetEnumerator As IEnumerator(Of VbaModule)
Returns
- System.Collections.Generic.IEnumerator<VbaModule>
A System.Collections.Generic.IEnumerator<T> that can be used to iterate through the collection.
Remove(VbaModule)
Removes the given VbaModule.
Parameters
Remove(String)
Removes the VbaModule by name.
Parameters
name
- System.String
Name of the VbaModule contained in the collection.
RemoveAt(Int32)
Removes the VbaModule from the given index.
Parameters
index
- System.Int32
The index of the VbaModule that will be removed.
TryGet(ExcelWorksheet, out VbaModule)
Tries to get the VbaModule with the specified excelWorksheet
.
public bool TryGet(ExcelWorksheet excelWorksheet, out VbaModule vbaModule)
Public Function TryGet(excelWorksheet As ExcelWorksheet, ByRef vbaModule As VbaModule) As Boolean
Parameters
excelWorksheet
- ExcelWorksheet
The ExcelWorksheet that binds VbaModule.
Returns
- System.Boolean
true if the collection contains an item that is bound to the excelWorksheet
; otherwise, false.
TryGet(String, out VbaModule)
Tries to get the VbaModule with the specified name
.
public bool TryGet(string name, out VbaModule vbaModule)
Public Function TryGet(name As String, ByRef vbaModule As VbaModule) As Boolean
Parameters
name
- System.String
Name of the VbaModule contained in the collection.
Returns
- System.Boolean
true if the collection contains an item with the name
; otherwise, false.