[GH-ISSUE #411] New feature: Add signature file for VBA projects #325

Closed
opened 2026-05-05 12:09:19 -06:00 by gitea-mirror · 1 comment
Owner

Originally created by @HolgiHo on GitHub (Sep 18, 2023).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/411

Originally assigned to: @jmcnamara on GitHub.

VBA projects can be digitally signed in Excel.

This is an important security feature for many commercial customers: Administrators or users can choose whether to block execution of unsigned VBA macros in their environment, for example, by editing a setting in the Excel Security Center dialog.

For details see the official documentation:
https://support.microsoft.com/en-us/office/change-macro-security-settings-in-excel-a97c09d2-c082-46b8-b19f-e8621e8fe373

Technically, the VBA signature file is named vbaProjectSignature.bin and is located in the same folder as vbaProject.bin. Some small additional changes are required in the xlsm file data file to make Excel accept the digital signature.

Digital signatures are added in VBA code editor window, menu Tools -> Digital Signatures. For details, again see the official documentation: https://support.microsoft.com/en-us/office/digitally-sign-your-vba-macro-project-956e9cc8-bbf6-4365-8bfa-98505ecd1c01

This feature was already requested in 2015 in the Python version of the library, see https://github.com/jmcnamara/XlsxWriter/issues/283. However, the PR never get merged as it missed the required contribution standards.

I have extended libxlsxwriter to support adding a VBA project digital signature file, including an example, a functional test, and documentation.

Here is an example for the C library. Note the new public function workbook_add_vba_project_signature. This is the only API extension I made.

lxw_workbook  *workbook  = workbook_new("macro_signed.xlsm");
lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);

/* Add a macro file extracted from an Excel workbook. */
workbook_add_vba_project(workbook, "vbaProject.bin");

/* Add a VBA project signature file extracted from an Excel workbook. */
workbook_add_vba_project_signature(workbook, "vbaProjectSignature.bin");

I will create the corresponding PR soon and put a reference here.

I have also added the feature to the Python version of the library, https://github.com/jmcnamara/XlsxWriter. I will open a similar issue there as well.

Originally created by @HolgiHo on GitHub (Sep 18, 2023). Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/411 Originally assigned to: @jmcnamara on GitHub. **VBA projects** can be **digitally signed** in Excel. This is an important **security feature** for many commercial customers: Administrators or users can choose whether to block execution of unsigned VBA macros in their environment, for example, by editing a setting in the Excel Security Center dialog. For details see the official documentation: https://support.microsoft.com/en-us/office/change-macro-security-settings-in-excel-a97c09d2-c082-46b8-b19f-e8621e8fe373 Technically, the VBA signature file is named vbaProjectSignature.bin and is located in the same folder as vbaProject.bin. Some small additional changes are required in the xlsm file data file to make Excel accept the digital signature. Digital signatures are added in VBA code editor window, menu Tools -> Digital Signatures. For details, again see the official documentation: https://support.microsoft.com/en-us/office/digitally-sign-your-vba-macro-project-956e9cc8-bbf6-4365-8bfa-98505ecd1c01 This feature was already requested in 2015 in the Python version of the library, see https://github.com/jmcnamara/XlsxWriter/issues/283. However, the PR never get merged as it missed the required contribution standards. I have extended libxlsxwriter to support adding a VBA project digital signature file, including an example, a functional test, and documentation. Here is an example for the C library. Note the new public function `workbook_add_vba_project_signature`. This is the only API extension I made. ``` lxw_workbook *workbook = workbook_new("macro_signed.xlsm"); lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL); /* Add a macro file extracted from an Excel workbook. */ workbook_add_vba_project(workbook, "vbaProject.bin"); /* Add a VBA project signature file extracted from an Excel workbook. */ workbook_add_vba_project_signature(workbook, "vbaProjectSignature.bin"); ``` I will create the corresponding PR soon and put a reference here. I have also added the feature to the Python version of the library, https://github.com/jmcnamara/XlsxWriter. I will open a similar issue there as well.
Author
Owner

@jmcnamara commented on GitHub (Sep 25, 2023):

Merged on main.

<!-- gh-comment-id:1733449618 --> @jmcnamara commented on GitHub (Sep 25, 2023): Merged on main.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/libxlsxwriter#325
No description provided.