Digitally Sign a VBA Code Project with Certificate using Node.js via C++
You can digitally sign your VBA code project using Aspose.Cells with its VbaProject.sign(DigitalSignature) method. Please follow these steps to check if your Excel file is digitally signed with a certificate.
- Click Visual Basic from the Developer tab to open Visual Basic for Applications IDE
- Click Tools > Digital Signatures… of Visual Basic for Applications IDE
and it will show the Digital Signature Form showing if the document is digitally signed with a certificate or not.
Digitally Sign a VBA Code Project with Certificate in Node.js
The following sample code illustrates how to make use of VbaProject.sign(DigitalSignature) method. Here are the input and output files of the sample code. You can use any Excel file and any certificate to test this code.
- Source Excel file used in the sample code.
- Sample pfx file to create Digital Signature. Please install it on your computer to run this code. Its password is 1234.
- Output Excel file generated by the sample code.
const fs = require("fs");
const path = require("path");
const AsposeCells = require("aspose.cells.node");
// Set up paths
const sourceDir = path.join(__dirname, "data");
const outputDir = path.join(__dirname, "output");
const pfxPath = path.join(sourceDir, "sampleDigitallySignVbaProjectWithCertificate.pfx");
const workbookPath = path.join(sourceDir, "sampleDigitallySignVbaProjectWithCertificate.xlsm");
// Set Digital Signature
const password = "1234";
const comment = "Signing Digital Signature using Aspose.Cells";
const digitalSignature = new AsposeCells.DigitalSignature(fs.readFileSync(pfxPath), password, comment, new Date());
// Create workbook object from excel file
const workbook = new AsposeCells.Workbook(workbookPath);
// Sign VBA Code Project with Digital Signature
workbook.getVbaProject().sign(digitalSignature);
// Save the workbook
workbook.save(path.join(outputDir, "outputDigitallySignVbaProjectWithCertificate.xlsm"));