VbaProjectReferenceCollection.AddRegisteredReference

VbaProjectReferenceCollection.AddRegisteredReference method

Add a reference to an Automation type library.

public int AddRegisteredReference(string name, string libid)
ParameterTypeDescription
nameStringThe name of reference.
libidStringThe identifier of an Automation type library.

Examples

using System;
using Aspose.Cells;
using Aspose.Cells.Vba;

namespace AsposeCellsExamples
{
    public class VbaProjectReferenceCollectionMethodAddRegisteredReferenceWithStringStringDemo
    {
        public static void Run()
        {
            // Create a new workbook
            Workbook workbook = new Workbook();
            
            // Access the VBA project
            VbaProject vbaProject = workbook.VbaProject;
            
            // Add a registered reference to stdole
            vbaProject.References.AddRegisteredReference(
                "stdole", 
                "*\\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\\Windows\\system32\\stdole2.tlb#OLE Automation");
            
            // Save the workbook
            workbook.Save("output.xlsm");
        }
    }
}

See Also