Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Aspose.Cells allows you to check if the VBA (Visual Basic for Applications) Project of an Excel file is protected and locked for viewing. For this, the API provides the VbaProject.GetIslockedForViewing() property. If it is locked for viewing, then the VbaProject.GetIslockedForViewing() property returns true.
The following sample code loads the sample Excel file and checks if the VBA (Visual Basic for Applications) Project of the Excel file is protected and locked for viewing. Please also see its Console Output for a reference.
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
using namespace Aspose::Cells::Vba;
int main()
{
Aspose::Cells::Startup();
// Source directory path
U16String srcDir(u"..\\Data\\01_SourceDirectory\\");
// Path of input Excel file
U16String inputFilePath = srcDir + u"sampleCheckifVBAProjectisProtected.xlsm";
// Load your source Excel file
Workbook wb(inputFilePath);
// Access the VBA project of the workbook
VbaProject vbaProject = wb.GetVbaProject();
// Check if "Lock project for viewing" is true or not
std::cout << "Is VBA Project Locked for Viewing: " << vbaProject.GetIslockedForViewing() << std::endl;
Aspose::Cells::Cleanup();
}
This is the console output of the above sample code when executed with the provided sample Excel file.
Is VBA Project Locked for Viewing: TrueAnalyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.