Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
You can find if the VBA (Visual Basic Applications) Project of your Excel file is protected or not with Aspose.Cells using VbaProject.IsProtected property.
The following sample code creates a workbook and then checks if its VBA project is protected or not. Then it protects the VBA project and again checks if its VBA project is protected or not. Please see its console output for a 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 for a reference.
IsProtected - Before Protecting VBA Project: False
IsProtected - After Protecting VBA Project: TrueAnalyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.