Fügen Sie einen Bibliotheksverweis zum VBA-Projekt in der Arbeitsmappe hinzu

Fügen Sie einen Bibliotheksverweis zum VBA-Projekt in Microsoft Excel hinzu

In Microsoft Excel können Sie dem VBA-Projekt einen Bibliotheksverweis hinzufügen, indem Sie auf klickenExtras > Referenzen… manuell.

Fügen Sie dem VBA-Projekt in einer Arbeitsmappe mit Aspose.Cells einen Bibliotheksverweis hinzu

Der folgende Beispielcode fügt dem VBA-Projekt der Arbeitsmappe zwei Bibliotheksverweise hinzu oder registriert sieVbaProject.References.AddRegisteredReference()Methode.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
string outputPath = dataDir + "Output_out.xlsm";
Workbook workbook = new Workbook();
VbaProject vbaProj = workbook.VbaProject;
vbaProj.References.AddRegisteredReference("stdole", "*\\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\\Windows\\system32\\stdole2.tlb#OLE Automation");
vbaProj.References.AddRegisteredReference("Office", "*\\G{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}#2.0#0#C:\\Program Files\\Common Files\\Microsoft Shared\\OFFICE14\\MSO.DLL#Microsoft Office 14.0 Object Library");
workbook.Save(outputPath);