现在的位置: 首页 > 综合 > 正文

在MS Outlook中, 使用SelfCert.exe为你的自定义宏做签名 – Signing your own macros with SelfCert.exe

2013年02月01日 ⁄ 综合 ⁄ 共 2223字 ⁄ 字号 评论关闭

When you create a macro and are running Outlook with the default security settings you are not able to run the macro unless you either tamper with the default security settings or sign your own code with a digital certificate. Since it is not very common to have your own digital certificate you probably set your macro security to a lower level to be able to run your macro. There is no need for that; you can sign your own macros with SelfCert.exe so there is no more need to lower your security settings.

 

Locating SelfCert.exe

By default you can find Selfcert.exe in the following location;
C:/Program Files/Microsoft Office/Office <version number>
If it is not there run Office setup and choose a custom installation and then advanced customization. Expand the Office Shared Features Section and select Digital Certificate for VBA Projects to run from your computer. For Office 2000 you can find this under the Office Tools section.

Using SelfCert.exe

Simply run SelfCert.exe. It will prompt you to name the certificate. I use my username because that is most convenient to me but you can also give it the name of your company or whatever you want.

Create Digital Certificate with SelfCert.exe
As explained in the dialog a selfcert is for personal use only

Signing your code

Back in the VBA Editor (ALT+F11) where you created the macro choose Tools-> Digital Signature. You’ll see that the current VBA project isn’t signed. Press the Choose… button and you’ll get a screen to select a certificate. Now you can choose the certificate you just created.

Choose certificate
Currently the project is unsigned

Select certificate
Select the certificate you just created

Running the signed macro for the first time

First let’s check if your macro security level is still set correctly. In the main Outlook window choose Tools-> Macro-> Security… and make sure it is set to “Warnings for signed macros; all unsigned macros are disabled” in Outlook 2007 and for any previous version it reads “High. Only signed macros from trusted sources will be allowed to run. Unsigned macros are automatically disabled.”

Now that we’ve signed the code and verified that the security settings are set correctly you must close Outlook. You’ll get prompted if you want save changes to your VBA project. Choose “Yes”. Once Outlook is fully closed start it again.

No that we’re all set you can run the macro by Tools-> Macro-> Macros… (ALT+F8). Since it is the first time that you are using the certificate you’ll be prompted what to do. Select that you’ll always trust the certificate from this publisher and you’re done! Now your own macros will run without any nasty security prompts and you can still enjoy Outlook with your security settings on high.

Trust Publisher
If you can’t trust yourself…

【上篇】
【下篇】

抱歉!评论已关闭.