Class VbaProjectReferenceCollection

VbaProjectReferenceCollection class

Represents all references of VBA project.

public class VbaProjectReferenceCollection : CollectionBase<VbaProjectReference>

Properties

NameDescription
Capacity { get; set; }
Count { get; }
Item { get; }Get the reference in the list by the index.
Item { get; set; }

Methods

NameDescription
AddControlRefrernce(string, string, string, string)Add a reference to a twiddled type library and its extended type library.
AddProjectRefrernce(string, string, string)Adds a reference to an external VBA project.
AddRegisteredReference(string, string)Add a reference to an Automation type library.
BinarySearch(VbaProjectReference)
BinarySearch(VbaProjectReference, IComparer<VbaProjectReference>)
BinarySearch(int, int, VbaProjectReference, IComparer<VbaProjectReference>)
Clear()
Contains(VbaProjectReference)
Copy(VbaProjectReferenceCollection)Copies references from other VBA project.
CopyTo(VbaProjectReference[])
CopyTo(VbaProjectReference[], int)
CopyTo(int, VbaProjectReference[], int, int)
Exists(Predicate<VbaProjectReference>)
Find(Predicate<VbaProjectReference>)
FindAll(Predicate<VbaProjectReference>)
FindIndex(Predicate<VbaProjectReference>)
FindIndex(int, Predicate<VbaProjectReference>)
FindIndex(int, int, Predicate<VbaProjectReference>)
FindLast(Predicate<VbaProjectReference>)
FindLastIndex(Predicate<VbaProjectReference>)
FindLastIndex(int, Predicate<VbaProjectReference>)
FindLastIndex(int, int, Predicate<VbaProjectReference>)
GetEnumerator()
IndexOf(VbaProjectReference)
IndexOf(VbaProjectReference, int)
IndexOf(VbaProjectReference, int, int)
LastIndexOf(VbaProjectReference)
LastIndexOf(VbaProjectReference, int)
LastIndexOf(VbaProjectReference, int, int)
RemoveAt(int)

Examples


[C#]

//Instantiating a Workbook object
Workbook workbook = new Workbook();
 // Init VBA project.
VbaProject vbaProject = workbook.VbaProject;
// Add vba project reference
vbaProject.References.AddRegisteredReference("stdole", "*\\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\\Windows\\system32\\stdole2.tlb#OLE Automation");
//Saving the Excel file
workbook.Save("book1.xlsm");

 [Visual Basic]

'Instantiating a Workbook object
Dim workbook As Workbook = New Workbook()
'Init VBA project.
Dim vbaProject as VbaProject  = workbook.VbaProject
'Add vba project reference
vbaProject.References.AddRegisteredReference("stdole", "*\\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\\Windows\\system32\\stdole2.tlb#OLE Automation")
'Saving the Excel file
workbook.Save("book1.xlsm")

See Also