Enum VbaModuleType

VbaModuleType enumeration

Represents the type of VBA module.

public enum VbaModuleType

Values

NameValueDescription
Procedural0Represents a procedural module.
Document1Represents a document module.
Class2Represents a class module.
Designer3Represents a designer module.

Examples

[C#]

namespace Demos
{
    using Aspose.Cells;
    using Aspose.Cells.Vba;
    using System;

    public class VbaModuleTypeDemo
    {
        public static void VbaModuleTypeExample()
        {
            // Instantiating a Workbook object
            Workbook workbook = new Workbook();
            
            // Init VBA project
            VbaProject vbaProject = workbook.VbaProject;
            
            // Add a new class module
            int index = vbaProject.Modules.Add(VbaModuleType.Class, "test");
            
            // Get the VBA module
            VbaModule vbaModule = vbaProject.Modules[index];
            
            // Set codes for the module
            vbaModule.Codes = "Sub ShowMessage()\r\nMsgBox \"Welcome to Aspose!\"\r\nEnd Sub";
            
            // Save the Excel file
            workbook.Save("VbaModuleTypeExample.xlsm");
        }
    }
}

See Also