Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
bow bow is offline
external usenet poster
 
Posts: 4
Default Programmatically signing Excel VBA Macro

Hi,
We want to sign a bunch of files with excel macros
programmatically.
Anyone knows of C#.Net or VB.Net solution?
Fileformat is excel 2007 (Open XML).

Thanks,
Mike
  #2   Report Post  
Posted to microsoft.public.excel.programming
bow bow is offline
external usenet poster
 
Posts: 4
Default Programmatically signing Excel VBA Macro

To clarify the request:
The step "Visual Basic = Tools = Digitial Signature"
have to be automated.

"bow" wrote:

Hi,
We want to sign a bunch of files with excel macros
programmatically.
Anyone knows of C#.Net or VB.Net solution?
Fileformat is excel 2007 (Open XML).

Thanks,
Mike

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Programmatically signing Excel VBA Macro

This is from the VBA help file. However, it requires that a digital
signature certificate be in existence.

Example
The following example prompts the user to select a digital signature with
which to sign the active document in Microsoft Word. To use this example,
open a document in Word and pass this function the name of a certificate
issuer and the name of a certificate signer that match the Issued By and
Issued To fields of a digital certificate in the Digital Certificates dialog
box. This example will test to make sure that the digital signature that the
user selects meets certain criteria, such as not having expired, before the
new signature is committed to the disk.

Function AddSignature(ByVal strIssuer As String, _
strSigner As String) As Boolean

On Error GoTo Error_Handler

Dim sig As Signature

'Display the dialog box that lets the
'user select a digital signature.
'If the user selects a signature, then
'it is added to the Signatures
'collection. If the user doesn't, then
'an error is returned.
Set sig = ActiveDocument.Signatures.Add

'Test several properties before commiting the Signature object to disk.
If sig.Issuer = strIssuer And _
sig.Signer = strSigner And _
sig.IsCertificateExpired = False And _
sig.IsCertificateRevoked = False And _
sig.IsValid = True Then

MsgBox "Signed"
AddSignature = True
'Otherwise, remove the Signature object from the SignatureSet collection.
Else
sig.Delete
MsgBox "Not signed"
AddSignature = False
End If

'Commit all signatures in the SignatureSet collection to the disk.
ActiveDocument.Signatures.Commit

Exit Function
Error_Handler:
AddSignature = False
MsgBox "Action cancelled."
End Function



"bow" wrote:

Hi,
We want to sign a bunch of files with excel macros
programmatically.
Anyone knows of C#.Net or VB.Net solution?
Fileformat is excel 2007 (Open XML).

Thanks,
Mike

  #4   Report Post  
Posted to microsoft.public.excel.programming
bow bow is offline
external usenet poster
 
Posts: 4
Default Programmatically signing Excel VBA Macro

Thanks for your answer - but:
The code you pasted below signs the _document_'s content.
What we need is a signature of the vba macros inside the document.
(DeveloperToolsDigital Signature).
This creates a file inside Open XML as vbaProjectsignature.bin file and
relates to vbaProject.bin file.

In contrast the document's signature (which is created with code below)
is stored as a standard XML-Signature [file sig2.xml].

Nevertheless, thanks a lot for your response.
rgds,
Mike

"JLGWhiz" wrote:

This is from the VBA help file. However, it requires that a digital
signature certificate be in existence.

Example
The following example prompts the user to select a digital signature with
which to sign the active document in Microsoft Word. To use this example,
open a document in Word and pass this function the name of a certificate
issuer and the name of a certificate signer that match the Issued By and
Issued To fields of a digital certificate in the Digital Certificates dialog
box. This example will test to make sure that the digital signature that the
user selects meets certain criteria, such as not having expired, before the
new signature is committed to the disk.

Function AddSignature(ByVal strIssuer As String, _
strSigner As String) As Boolean

On Error GoTo Error_Handler

Dim sig As Signature

'Display the dialog box that lets the
'user select a digital signature.
'If the user selects a signature, then
'it is added to the Signatures
'collection. If the user doesn't, then
'an error is returned.
Set sig = ActiveDocument.Signatures.Add

'Test several properties before commiting the Signature object to disk.
If sig.Issuer = strIssuer And _
sig.Signer = strSigner And _
sig.IsCertificateExpired = False And _
sig.IsCertificateRevoked = False And _
sig.IsValid = True Then

MsgBox "Signed"
AddSignature = True
'Otherwise, remove the Signature object from the SignatureSet collection.
Else
sig.Delete
MsgBox "Not signed"
AddSignature = False
End If

'Commit all signatures in the SignatureSet collection to the disk.
ActiveDocument.Signatures.Commit

Exit Function
Error_Handler:
AddSignature = False
MsgBox "Action cancelled."
End Function



"bow" wrote:

Hi,
We want to sign a bunch of files with excel macros
programmatically.
Anyone knows of C#.Net or VB.Net solution?
Fileformat is excel 2007 (Open XML).

Thanks,
Mike

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Programmatically signing Excel VBA Macro

I'm having the same problem and it seems that there is nothing on internet
about that elsewhere...
Did you find any solution ??

Thanks
--
Thibaut

"bow" wrote:

Thanks for your answer - but:
The code you pasted below signs the _document_'s content.
What we need is a signature of the vba macros inside the document.
(DeveloperToolsDigital Signature).
This creates a file inside Open XML as vbaProjectsignature.bin file and
relates to vbaProject.bin file.

In contrast the document's signature (which is created with code below)
is stored as a standard XML-Signature [file sig2.xml].

Nevertheless, thanks a lot for your response.
rgds,
Mike

"JLGWhiz" wrote:

This is from the VBA help file. However, it requires that a digital
signature certificate be in existence.

Example
The following example prompts the user to select a digital signature with
which to sign the active document in Microsoft Word. To use this example,
open a document in Word and pass this function the name of a certificate
issuer and the name of a certificate signer that match the Issued By and
Issued To fields of a digital certificate in the Digital Certificates dialog
box. This example will test to make sure that the digital signature that the
user selects meets certain criteria, such as not having expired, before the
new signature is committed to the disk.

Function AddSignature(ByVal strIssuer As String, _
strSigner As String) As Boolean

On Error GoTo Error_Handler

Dim sig As Signature

'Display the dialog box that lets the
'user select a digital signature.
'If the user selects a signature, then
'it is added to the Signatures
'collection. If the user doesn't, then
'an error is returned.
Set sig = ActiveDocument.Signatures.Add

'Test several properties before commiting the Signature object to disk.
If sig.Issuer = strIssuer And _
sig.Signer = strSigner And _
sig.IsCertificateExpired = False And _
sig.IsCertificateRevoked = False And _
sig.IsValid = True Then

MsgBox "Signed"
AddSignature = True
'Otherwise, remove the Signature object from the SignatureSet collection.
Else
sig.Delete
MsgBox "Not signed"
AddSignature = False
End If

'Commit all signatures in the SignatureSet collection to the disk.
ActiveDocument.Signatures.Commit

Exit Function
Error_Handler:
AddSignature = False
MsgBox "Action cancelled."
End Function



"bow" wrote:

Hi,
We want to sign a bunch of files with excel macros
programmatically.
Anyone knows of C#.Net or VB.Net solution?
Fileformat is excel 2007 (Open XML).

Thanks,
Mike



  #6   Report Post  
Posted to microsoft.public.excel.programming
bow bow is offline
external usenet poster
 
Posts: 4
Default Programmatically signing Excel VBA Macro

Alas no ... I'm still searching for a solution.

"Thibaut Blanchin" wrote:

I'm having the same problem and it seems that there is nothing on internet
about that elsewhere...
Did you find any solution ??

Thanks
--
Thibaut

"bow" wrote:

Thanks for your answer - but:
The code you pasted below signs the _document_'s content.
What we need is a signature of the vba macros inside the document.
(DeveloperToolsDigital Signature).
This creates a file inside Open XML as vbaProjectsignature.bin file and
relates to vbaProject.bin file.

In contrast the document's signature (which is created with code below)
is stored as a standard XML-Signature [file sig2.xml].

Nevertheless, thanks a lot for your response.
rgds,
Mike

"JLGWhiz" wrote:

This is from the VBA help file. However, it requires that a digital
signature certificate be in existence.

Example
The following example prompts the user to select a digital signature with
which to sign the active document in Microsoft Word. To use this example,
open a document in Word and pass this function the name of a certificate
issuer and the name of a certificate signer that match the Issued By and
Issued To fields of a digital certificate in the Digital Certificates dialog
box. This example will test to make sure that the digital signature that the
user selects meets certain criteria, such as not having expired, before the
new signature is committed to the disk.

Function AddSignature(ByVal strIssuer As String, _
strSigner As String) As Boolean

On Error GoTo Error_Handler

Dim sig As Signature

'Display the dialog box that lets the
'user select a digital signature.
'If the user selects a signature, then
'it is added to the Signatures
'collection. If the user doesn't, then
'an error is returned.
Set sig = ActiveDocument.Signatures.Add

'Test several properties before commiting the Signature object to disk.
If sig.Issuer = strIssuer And _
sig.Signer = strSigner And _
sig.IsCertificateExpired = False And _
sig.IsCertificateRevoked = False And _
sig.IsValid = True Then

MsgBox "Signed"
AddSignature = True
'Otherwise, remove the Signature object from the SignatureSet collection.
Else
sig.Delete
MsgBox "Not signed"
AddSignature = False
End If

'Commit all signatures in the SignatureSet collection to the disk.
ActiveDocument.Signatures.Commit

Exit Function
Error_Handler:
AddSignature = False
MsgBox "Action cancelled."
End Function



"bow" wrote:

Hi,
We want to sign a bunch of files with excel macros
programmatically.
Anyone knows of C#.Net or VB.Net solution?
Fileformat is excel 2007 (Open XML).

Thanks,
Mike

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Programmatically signing Excel VBA Macro

OK... :-(
I will let you know if I finally find something.

--
Thibaut


"bow" wrote:

Alas no ... I'm still searching for a solution.

"Thibaut Blanchin" wrote:

I'm having the same problem and it seems that there is nothing on internet
about that elsewhere...
Did you find any solution ??

Thanks
--
Thibaut

"bow" wrote:

Thanks for your answer - but:
The code you pasted below signs the _document_'s content.
What we need is a signature of the vba macros inside the document.
(DeveloperToolsDigital Signature).
This creates a file inside Open XML as vbaProjectsignature.bin file and
relates to vbaProject.bin file.

In contrast the document's signature (which is created with code below)
is stored as a standard XML-Signature [file sig2.xml].

Nevertheless, thanks a lot for your response.
rgds,
Mike

"JLGWhiz" wrote:

This is from the VBA help file. However, it requires that a digital
signature certificate be in existence.

Example
The following example prompts the user to select a digital signature with
which to sign the active document in Microsoft Word. To use this example,
open a document in Word and pass this function the name of a certificate
issuer and the name of a certificate signer that match the Issued By and
Issued To fields of a digital certificate in the Digital Certificates dialog
box. This example will test to make sure that the digital signature that the
user selects meets certain criteria, such as not having expired, before the
new signature is committed to the disk.

Function AddSignature(ByVal strIssuer As String, _
strSigner As String) As Boolean

On Error GoTo Error_Handler

Dim sig As Signature

'Display the dialog box that lets the
'user select a digital signature.
'If the user selects a signature, then
'it is added to the Signatures
'collection. If the user doesn't, then
'an error is returned.
Set sig = ActiveDocument.Signatures.Add

'Test several properties before commiting the Signature object to disk.
If sig.Issuer = strIssuer And _
sig.Signer = strSigner And _
sig.IsCertificateExpired = False And _
sig.IsCertificateRevoked = False And _
sig.IsValid = True Then

MsgBox "Signed"
AddSignature = True
'Otherwise, remove the Signature object from the SignatureSet collection.
Else
sig.Delete
MsgBox "Not signed"
AddSignature = False
End If

'Commit all signatures in the SignatureSet collection to the disk.
ActiveDocument.Signatures.Commit

Exit Function
Error_Handler:
AddSignature = False
MsgBox "Action cancelled."
End Function



"bow" wrote:

Hi,
We want to sign a bunch of files with excel macros
programmatically.
Anyone knows of C#.Net or VB.Net solution?
Fileformat is excel 2007 (Open XML).

Thanks,
Mike

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Programmatically signing Excel VBA Macro

In message
at 06:46:03 on Fri, 31 Aug 2007, bow
wrote
To clarify the request:
The step "Visual Basic = Tools = Digitial Signature"
have to be automated.

"bow" wrote:

Hi,
We want to sign a bunch of files with excel macros
programmatically.
Anyone knows of C#.Net or VB.Net solution?
Fileformat is excel 2007 (Open XML).

Thanks,
Mike


Mmmm, it kinda defeats the whole point of what digital certificates are
for doesn't it if you could sign files external to the one running the
program
--
Mike News
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Having Trouble Digitally signing a macro JHL Excel Discussion (Misc queries) 0 August 31st 08 07:13 PM
Signing a macro Steven Excel Programming 3 January 26th 07 01:25 AM
loading a macro programmatically in excel VBA or perl surf Excel Programming 0 March 22nd 06 11:10 PM
Code signing a VBA macro in 2002 and 2003 Stephen Davies Excel Programming 5 April 6th 05 02:03 AM
programmatically changing priority of running excel macro at runti Bing Excel Programming 3 December 26th 04 08:18 PM


All times are GMT +1. The time now is 05:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"