How to programmatically remove the digital signature from VBA macros in Excel?

﹥>﹥吖頭↗ 提交于 2019-12-10 11:15:41

问题


Is there any way to programmatically remove the digital signature from the VBA macros of an Excel sheet?

i.e. code that is equivalent to entering the VBA editor, going to Tools menu -> Digital Signature and clicking Remove.


回答1:


Interesting question. It's deliberately not part of the Excel object model for security reasons.

It is possible to remove the certificate from the certificate store. This requires Win32 api calls (which can be made from VB6 or VBA but I'm not sure of the exact effect on your project once you do this... It will definately invalidate the certificate, but I don't know if it will remove it. Also you may not wish to remove the certificate from the store (since you could be using it for something else).

To view the certificate store, type, certmgr.msc at the Run prompt.

anyway a link on how to remove a certificate programmatically.
KB article showing how to remove a trusted root certificate from the store.

Requirements:
1. You'll need to download the Windows SDK for the appropriate platform to get the capicom dll's, + regsvr32 them 2. You'll need to extract the public key from the certifcate you want to remove.
3. Test with a uninmportant workbook first, I have no idea whether this method will (apart from invalidating the certificate) also cause corruption in the workbook. Hopefully someone has a better suggestion than this.



来源:https://stackoverflow.com/questions/1201195/how-to-programmatically-remove-the-digital-signature-from-vba-macros-in-excel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!