Class VbaModule

Class VbaModule

Namespace: Aspose.Cells.Vba
Assembly: Aspose.Cells.dll (25.2.0)

Represents the module in VBA project.

public class VbaModule

Inheritance

objectVbaModule

Inherited Members

object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Examples

//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");
'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")

Properties

Codes

Gets and sets the codes of module.

public string Codes { get; set; }

Property Value

string

Name

Gets and sets the name of Module.

public string Name { get; set; }

Property Value

string

Type

Gets the type of module.

public VbaModuleType Type { get; }

Property Value

VbaModuleType