Fügen Sie eine Bibliotheksreferenz zum VBA Projekt in der Arbeitsmappe hinzu
Contents
[
Hide
]
Manchmal müssen Sie den Bibliotheksverweis in das VBA-Projekt durch Code hinzufügen oder registrieren. Sie können dies mit der Methode VbaProject.References.AddRegisteredReference() von Aspose.Cells tun.
Fügen Sie einem VBA-Projekt in Microsoft Excel einen Bibliotheksverweis hinzu.
In Microsoft Excel können Sie manuell durch Klicken auf Extras > Verweise… einen Bibliotheksverweis auf das VBA-Projekt hinzufügen.
Fügen Sie einem Arbeitsmappen-VBA-Projekt einen Bibliotheksverweis mit Aspose.Cells hinzu.
Der folgende Beispielcode fügt oder registriert zwei Bibliotheksreferenzen im VBA-Projekt der Arbeitsmappe mithilfe der Methode VbaProject.References.AddRegisteredReference() hinzu.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |