VBA プロジェクトが保護されているかどうかを調べる
Contents
[
Hide
]
考えられる使用シナリオ
ExcelファイルのVBA(Visual Basic Applications)プロジェクトが保護されているかどうかは、Aspose.Cellsを使用して確認できますVbaProject.isProtected()方法
サンプルコード
次のサンプル コードは、ブックを作成し、その VBA プロジェクトが保護されているかどうかを確認します。次に、VBA プロジェクトを保護し、VBA プロジェクトが保護されているかどうかを再度確認します。コンソール出力を参照してください。保護前に、VbaProject.isProtected()戻り値間違いしかし、保護の後、それは戻ってきます真実.
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()); |
コンソール出力
これは、参照用の上記のサンプル コードのコンソール出力です。
IsProtected - Before Protecting VBA Project: false
IsProtected - After Protecting VBA Project: true