简体   繁体   English

有没有办法以编程方式向Word文档中的VBA宏添加数字签名?

[英]Is there a way to programmatically add a digital signature to a VBA Macro in a word document?

Is there a way to programmatically add a digital signature to a VBA Macro in a word document using C# or VB.Net? 有没有办法使用C#或VB.Net以编程方式将数字签名添加到Word文档中的VBA宏?

There are some similar questions asked already; 已经问过一些类似的问题。 however, none that I could find answer my question: How to programmatically remove the digital signature from VBA macros in Excel? 但是,没有一个我能回答我的问题: 如何以编程方式从Excel中的VBA宏中删除数字签名? Digital Signature for Excel Macro Excel宏的数字签名

Unfortunately, there isn't an automation API for this in the VBA environment. 不幸的是,VBA环境中没有针对此的自动化API。 I got it working 100% unattended (so I could use it in automated builds) by P/Invoking Win32 APIs to grab the right window handles and simulate the keyboard shortcuts to those windows, highlight the right cert, etc. Even had it working to detect and capture compilation errors (grab the error dialog window and dig out the label control text). 通过P /调用Win32 API,我可以使它100%无人值守工作(因此我可以在自动构建中使用它),以获取正确的窗口句柄并模拟这些窗口的键盘快捷键,突出显示正确的证书,等等。检测并捕获编译错误(抓住错误对话框窗口并挖出标签控件文本)。 It took me a few days of hacking to get it working reliably, but it is possible, and really not even that hard. 我花了几天的时间来破解它,以使其可靠地工作,但是这是可能的,而且实际上还没有那么难。

I'd be happy to post it, but my previous employer owns the code. 我很乐意将其发布,但是我以前的老板拥有该代码。 :( :(

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM