Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
You can determine whether the VBA (Visual Basic for Applications) project of your Excel file is protected using Aspose.Cells via the VbaProject.IsProtected property.
The following sample code creates a workbook, checks if its VBA project is protected, then protects the VBA project and checks again. Please see its console output for reference. Before protection, VbaProject.IsProtected returns false, but after protection, it returns true.
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
int main()
{
Aspose::Cells::Startup();
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C
// Create a workbook.
Workbook wb;
// Access the VBA project of the workbook.
VbaProject vbaProj = wb.GetVbaProject();
// Check if VBA Project is Protected using IsProtected method.
std::wcout << L"IsProtected - Before Protecting VBA Project: " << (vbaProj.IsProtected() ? L"True" : L"False") << std::endl;
// Protect the VBA project.
vbaProj.Protect(true, u"11");
// Check if VBA Project is Protected using IsProtected method.
std::wcout << L"IsProtected - After Protecting VBA Project: " << (vbaProj.IsProtected() ? L"True" : L"False") << std::endl;
Aspose::Cells::Cleanup();
}
This is the console output of the above sample code as a reference.
IsProtected - Before Protecting VBA Project: False
IsProtected - After Protecting VBA Project: True
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.