Aspose::Cells::Vba::VbaModule class

VbaModule class

Represents the module in VBA project.

class VbaModule

Methods

MethodDescription
GetCodes()Gets and sets the codes of module.
GetName()Gets and sets the name of Module.
GetType()Gets the type of module.
IsNull() constChecks whether the implementation object is nullptr.
explicit operator bool() constoperator bool()
operator=(const VbaModule& src)operator=
SetCodes(const U16String& value)Gets and sets the codes of module.
SetCodes(const char16_t* value)Gets and sets the codes of module.
SetName(const U16String& value)Gets and sets the name of Module.
SetName(const char16_t* value)Gets and sets the name of Module.
VbaModule(VbaModule_Impl* impl)Constructs from an implementation object.
VbaModule(const VbaModule& src)Copy constructor.
~VbaModule()Destructor.

Fields

FieldDescription
_implThe implementation object.

Examples

Aspose::Cells::Startup();
//Instantiating a Workbook object
Workbook workbook;
// Init VBA project.
VbaProject vbaProject = workbook.GetVbaProject();
// Add a new module.
int index = vbaProject.GetModules().Add(VbaModuleType::Class, u"test");
// Get vba module
VbaModule vbaModule = vbaProject.GetModules().Get(index);
// Set codes
vbaModule.SetCodes(u"Sub ShowMessage()\r\nMsgBox \"Welcome to Aspose!\"\r\nEnd Sub");
//Saving the Excel file
workbook.Save(u"book1.xlsm");

Aspose::Cells::Cleanup();

See Also