Scopri se il progetto VBA è protetto
Contents
[
Hide
]
Possibili scenari di utilizzo
Puoi scoprire se il progetto VBA (Visual Basic Applications) del tuo file Excel è protetto o meno con Aspose.Cells utilizzandoVbaProject.isProtected()metodo
Codice d’esempio
Il seguente codice di esempio crea una cartella di lavoro e quindi controlla se il relativo progetto VBA è protetto o meno. Quindi protegge il progetto VBA e controlla nuovamente se il suo progetto VBA è protetto o meno. Si prega di vedere l’output della sua console per un riferimento. Prima della protezione,VbaProject.isProtected() ritornafalso ma dopo la protezione, ritornaVERO.
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-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()); |
Uscita console
Questo è l’output della console del codice di esempio precedente come riferimento.
IsProtected - Before Protecting VBA Project: false
IsProtected - After Protecting VBA Project: true