Herausfinden, ob das VBA Projekt geschützt ist
Mögliche Verwendungsszenarien
Sie können mit Aspose.Cells mithilfe der Methode VbaProject.isProtected() feststellen, ob das VBA (Visual Basic Applications)-Projekt Ihrer Excel-Datei geschützt ist oder nicht.
Beispielcode
Der folgende Beispielcode erstellt eine Arbeitsmappe und überprüft dann, ob das VBA-Projekt geschützt ist oder nicht. Anschließend schützt es das VBA-Projekt und überprüft erneut, ob das VBA-Projekt geschützt ist oder nicht. Bitte sehen Sie die Konsolenausgabe als Referenz an. Vor dem Schutz gibt VbaProject.isProtected() false zurück, aber nach dem Schutz gibt es true zurück.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
// Create a workbook. | |
Workbook wb = new Workbook(); | |
// Access the VBA project of the workbook. | |
VbaProject vbaProj = wb.getVbaProject(); | |
// Find out if VBA Project is Protected using IsProtected property. | |
System.out.println("IsProtected - Before Protecting VBA Project: " + vbaProj.isProtected()); | |
// Protect the VBA project. | |
vbaProj.protect(true, "11"); | |
// Find out if VBA Project is Protected using IsProtected property. | |
System.out.println("IsProtected - After Protecting VBA Project: " + vbaProj.isProtected()); |
Konsolenausgabe
Dies ist die Konsolenausgabe des obigen Beispielcodes als Referenz.
IsProtected - Before Protecting VBA Project: false
IsProtected - After Protecting VBA Project: true