VbaProjectReferenceCollection.AddProjectRefrernce

VbaProjectReferenceCollection.AddProjectRefrernce method

Adds a reference to an external VBA project.

public int AddProjectRefrernce(string name, string absoluteLibid, string relativeLibid)
ParameterTypeDescription
nameStringThe name of reference.
absoluteLibidStringThe referenced VBA project’s identifier with an absolute path.
relativeLibidStringThe referenced VBA project’s identifier with an relative path.

Examples

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

namespace AsposeCellsExamples
{
    public class VbaProjectReferenceCollectionMethodAddProjectRefrernceWithStringStringStringDemo
    {
        public static void Run()
        {
            // Create a new workbook
            Workbook workbook = new Workbook();
            
            // Initialize VBA project
            VbaProject vbaProject = workbook.VbaProject;
            
            // Add a project reference with absolute and relative libids
            vbaProject.References.AddProjectRefrernce("MyProject", "absoluteLibid", "relativeLibid");
            
            // Display reference count
            Console.WriteLine("Total References: " + vbaProject.References.Count);
            
            // Save the workbook
            workbook.Save("VbaProjectReferenceExample.xlsm");
        }
    }
}

See Also