VbaModule Class

Represents the module in VBA project.
Inheritance Hierarchy
SystemObject
  Aspose.Cells.VbaVbaModule

Namespace:  Aspose.Cells.Vba
Assembly:  Aspose.Cells (in Aspose.Cells.dll) Version: 22.5.0.0 (22.5.0)
Syntax
public class VbaModule

The VbaModule type exposes the following members.

Properties
  NameDescription
Public propertyCodes
Gets and sets the codes of module.
Public propertyName
Gets and sets the name of Module.
Public propertyType
Gets the type of module.
Methods
  NameDescription
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodToString (Inherited from Object.)
Examples
[C#]

//Instantiating a Workbook object
Workbook workbook = new Workbook();
 // Init VBA project.
VbaProject vbaProject = workbook.VbaProject; 
// Add a new module.
int index = vbaProject.Modules.Add(VbaModuleType.Class, "test");
// Get vba module
VbaModule vbaModule = vbaProject.Modules[index];
// Set codes
vbaModule.Codes = "Sub ShowMessage()\r\nMsgBox \"Welcome to Aspose!\"\r\nEnd Sub";
//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.
Dim index as Integer = vbaProject.Modules.Add(VbaModuleType.Class, "test")
'Get vba module
Dim vbaModule as VbaModule = vbaProject.Modules(index)
'Set codes
vbaModule.Codes = "Sub ShowMessage()\r\nMsgBox \"Welcome to Aspose!\"\r\nEnd Sub"
'Saving the Excel file
workbook.Save("book1.xlsm")
See Also