Verifica se il progetto VBA è protetto e bloccato per la visualizzazione

Verifica se il Progetto VBA è Protetto e Bloccato per la Visualizzazione in C#

Aspose.Cells ti permette di verificare se il Progetto VBA (Visual Basic for Applications) del file Excel è protetto e bloccato per la visualizzazione. Per questo, l’API fornisce la proprietà VbaProject.IslockedForViewing. Se è bloccato per la visualizzazione, allora la proprietà VbaProject.IslockedForViewing restituisce true.

Codice di Esempio

Il seguente codice di esempio carica il file Excel di esempio e verifica se il Progetto VBA (Visual Basic for Applications) del file Excel è protetto e bloccato per la visualizzazione. Si prega di vedere anche l’Output della Console per ulteriori informazioni.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
//Load your source Excel file.
Workbook wb = new Workbook(dataDir + "sampleCheckifVBAProjectisProtected.xlsm");
//Access the VBA project of the workbook.
Aspose.Cells.Vba.VbaProject vbaProject = wb.VbaProject;
//Whether "Lock project for viewing" is true or not.
Console.WriteLine("Is VBA Project Locked for Viewing: " + vbaProject.IslockedForViewing);

Output della console

Questo è l’output della console del codice di esempio precedente quando eseguito con il file Excel di esempio fornito.

Is VBA Project Locked for Viewing: True