检查VBA项目是否受保护并已锁定以供查看
Contents
[
Hide
]
在Python中检查VBA项目是否被保护并锁定以供查看
Aspose.Cells for Python via .NET允许您检查Excel文件的VBA(Visual Basic for Applications)项目是否受到保护且被锁定以供查看。对此,API提供了VbaProject.islocked_for_viewing属性。如果被锁定查看,则VbaProject.islocked_for_viewing属性返回true。
示例代码
以下示例代码加载了示例Excel文件,并检查Excel文件的VBA(Visual Basic for Applications)项目是否受到保护并锁定以供查看。还请参见其控制台输出以供参考。
This file contains hidden or 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
from aspose.cells import Workbook | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# The path to the documents directory. | |
dataDir = RunExamples.GetDataDir(".") | |
# Load your source Excel file. | |
wb = Workbook(dataDir + "sampleCheckifVBAProjectisProtected.xlsm") | |
# Access the VBA project of the workbook. | |
vbaProject = wb.vba_project | |
# Whether "Lock project for viewing" is true or not. | |
print("Is VBA Project Locked for Viewing: " + str(vbaProject.islocked_for_viewing)) |
控制台输出
这是上述示例代码在使用提供的示例Excel文件时执行时的控制台输出。
Is VBA Project Locked for Viewing: True