Article posted by Ambily.Raj
on 9/26/2012 | Views: 1424 | Category: Error and Resolution
| Level: Intermediate | Points: 250
When we work on a Macro enabled excel file with digital certificate, most of us faced the issue - “There was a problem with the digital certificate. The VBA project could not be signed. The signature will be discarded”. Today we will look a little deeper into the issue.
When trying to save the excel after
assigning a digital certificate to the VBA project , receiving the
“There was a problem with the digital certificate. The VBA project could
not be signed. The signature will be discarded”.
Repro the issue:
1. Launch the Visual Studio Command prompt
-> All Programs -> Microsoft Visual Studio 2010 -> Visual Studio Tools
-> Visual Studio Command Prompt
Create the certificate authority using the makecert
makecert -n "CN=TestCA"
-cy authority -a sha1 -sv "TestCAPK.pvk" -r "TestCA.cer"
Specify the password.
Create the certificate
"TestCA.cer" -iv "TestCAPK.pvk" -a sha1 -sky signature
Specify the password.
Now combine the private key and certificate to pfx file
"TestTestPK.pvk" -spc "TestTestCert.cer" -pfx
"TestTestCert.pfx" -pi Test@123
open the certificate store and import the certificate
"TestTestCert.cer" into Personal node. Remember the digital
certificates appearing under the VBA editor window is from Personal node only.
try to use the certificate in your Macro.
1. Open Excel sheet
2. Click on Developer Tab
3. Select Visual Basic under Code section
4. Enter the Macro Code in Microsoft Visual basic for
5. Now, select the Digital Signature option from Tools menu.
6. This will open the Digital Signature Window. Select Choose to
Select new certificate
7. Select our certificate from the Select a Certificate window.
8. Click OK
9. Click OK in Digital Signature Window.
10. Now Save the Macro enabled Excel. This will throw the
go back to the certificate store and import the pfx file into Personal node.
Open the VBA editor window
from the Excel sheet and try to sign using the Digital Signature. This time
excel will save successfully.
If you like this article, subscribe to our RSS Feed. You can also subscribe via email to our Interview Questions, Codes and Forums section.
Found interesting? Add this to: