如何以编程方式将证书分配给excel宏 [英] How to assign certificates to excel macros programmatically

查看:143
本文介绍了如何以编程方式将证书分配给excel宏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发了一些创建excel宏的代码,每次创建新宏之后,我想以编程方式对宏进行数字签名。如果有任何方式使用我可以创建新的数字证书并以编程方式将其分配给宏,您能否让我知道。谢谢。

I have developed some code which creates excel macros and each time after creation of new macro I want to digitally sign the macro programmatically. Can you let me know if there is any way using which I can create new digital certificates and assign those to macro programmatically. Thanks.

推荐答案

不可能使用VBA代码执行此操作。我认为最好的方法是通过使Win32 API调用来模拟所有需要的步骤来实现。这将是马虎,但你可以使它的工作。基本上,您可以使用键盘上的快捷键打开所需的窗口和应用程序,并选择正确的证书。

It is not possible to do this with VBA code. I think the best you could hope to do it would be by making Win32 API calls to simulate all the needed steps to make this happen. It would be sloppy but you could make it work. Basically, you would have open the needed windows and applications leveraging shortcut keys on the keyboard and for selecting the correct certs.

某些示例代码将是

Public Declare Function SetFocus Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
    (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
    (ByVal hWnd1 As Long, ByVal hWnd2 As Long, _
    ByVal lpsz1 As String, ByVal lpsz2 As String) As Long

Sub SetFocusFormulaBar()
    SetFocus FindWindowEx(FindWindow("XLMAIN", Application.Caption), _
        0&, "EXCEL<", vbNullString)
End Sub

http://www.cpearson.com/excel/FormulaBarShortcut.htm

这篇关于如何以编程方式将证书分配给excel宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆