Finden Sie heraus, ob das VBA-Projekt geschützt ist

Mögliche Nutzungsszenarien

Ob das VBA-Projekt (Visual Basic Applications) Ihrer Excel-Datei geschützt ist oder nicht, können Sie mit Aspose.Cells feststellenVbaProject.isProtected()Methode

Beispielcode

Der folgende Beispielcode erstellt eine Arbeitsmappe und überprüft dann, ob ihr VBA-Projekt geschützt ist oder nicht. Dann schützt es das VBA-Projekt und überprüft erneut, ob sein VBA-Projekt geschützt ist oder nicht. Bitte sehen Sie sich die Konsolenausgabe für eine Referenz an. Vor Schutz,VbaProject.isProtected() kehrt zurückFALSCH aber nach dem Schutz kehrt es zurückwahr.

// 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