Herausfinden, ob das VBA Projekt geschützt ist
Ermitteln, ob VBA-Projekt geschützt ist in Python
Sie können feststellen, ob das VBA- (Visual Basic für Applikationen-) Projekt Ihrer Excel-Datei mit Aspose.Cells for Python via .NET geschützt ist oder nicht, mit der VbaProject.is_protected-Eigenschaft.
Beispielcode
Der folgende Beispielscode erstellt eine Arbeitsmappe und überprüft dann, ob ihr VBA-Projekt geschützt ist oder nicht. Anschließend schützt es das VBA-Projekt und überprüft erneut, ob ihr VBA-Projekt geschützt ist oder nicht. Bitte sehen Sie sich die Konsolenausgabe zur Referenz an. Vor dem Schutz gibt VbaProject.is_protected false zurück, aber nach dem Schutz gibt sie true zurück.
from aspose.cells import Workbook | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# Create a workbook. | |
wb = Workbook() | |
# Access the VBA project of the workbook. | |
vbaProj = wb.vba_project | |
# Find out if VBA Project is Protected using IsProtected property. | |
print("IsProtected - Before Protecting VBA Project: " + str(vbaProj.is_protected)) | |
# Protect the VBA project. | |
vbaProj.protect(True, "11") | |
# Find out if VBA Project is Protected using IsProtected property. | |
print("IsProtected - After Protecting VBA Project: " + str(vbaProj.is_protected)) |
Konsolenausgabe
Dies ist die Konsolenausgabe des obigen Beispielcodes als Referenz.
IsProtected - Before Protecting VBA Project: False
IsProtected - After Protecting VBA Project: True