Protéger par mot de passe le projet VBA du classeur Excel avec Node.js via C++
Protéger par mot de passe le projet VBA du classeur Excel dans Node.js
Vous pouvez protéger par mot de passe le projet VBA (Visual Basic for Applications) d’un classeur avec Aspose.Cells en utilisant la méthode VbaProject.protect(boolean, string).
Code d’exemple
Le code exemple suivant charge le fichier Excel d’exemple, accède à son projet VBA et le protège par un mot de passe. Enfin, il le sauvegarde en tant que fichier Excel de sortie.
const path = require("path");
const AsposeCells = require("aspose.cells.node");
// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
// Load your source Excel file.
const workbook = new AsposeCells.Workbook(path.join(dataDir, "samplePasswordProtectVBAProject.xlsm"));
// Access the VBA project of the workbook.
const vbaProject = workbook.getVbaProject();
// Lock the VBA project for viewing with password.
vbaProject.protect(true, "11");
// Save the output Excel file
workbook.save(path.join(dataDir, "outputPasswordProtectVBAProject.xlsm"));