Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / September 2007

Tip: Looking for answers? Try searching our database.

Programmatically signing Excel VBA Macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bow - 31 Aug 2007 14:44 GMT
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
bow - 31 Aug 2007 14:46 GMT
To clarify the request:
The step "Visual Basic => Tools => Digitial Signature"
have to be automated.

> Hi,
> We want to sign a bunch of files with excel macros
[quoted text clipped - 4 lines]
> Thanks,
> Mike
Mike - 29 Sep 2007 10:21 GMT
In message <92FDF437-CD95-46E1-ADEE-D38E7CE04CFB@microsoft.com>
at 06:46:03 on Fri, 31 Aug 2007, bow <bow@discussions.microsoft.com>
wrote
>To clarify the request:
>The step "Visual Basic => Tools => Digitial Signature"
[quoted text clipped - 8 lines]
>> 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
Signature

Mike News

JLGWhiz - 31 Aug 2007 15:14 GMT
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
       

> Hi,
> We want to sign a bunch of files with excel macros
[quoted text clipped - 4 lines]
> Thanks,
> Mike
bow - 31 Aug 2007 16:34 GMT
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.
(Developer>Tools>Digital 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

> This is from the VBA help file.  However, it requires that a digital
> signature certificate be in existence.
[quoted text clipped - 58 lines]
> > Thanks,
> > Mike
Thibaut Blanchin - 25 Sep 2007 15:16 GMT
I'm having the same problem and it seems that there is nothing on internet
about that elsewhere...
Did you find any solution ??

Thanks
Signature

Thibaut

> Thanks for your answer - but:
> The code you pasted below signs the _document_'s content.
[quoted text clipped - 72 lines]
> > > Thanks,
> > > Mike
bow - 25 Sep 2007 15:46 GMT
Alas no ... I'm still searching for a solution.

> I'm having the same problem and it seems that there is nothing on internet
> about that elsewhere...
[quoted text clipped - 78 lines]
> > > > Thanks,
> > > > Mike
Thibaut Blanchin - 25 Sep 2007 16:06 GMT
OK... :-(
I will let you know if I finally find something.

Signature

Thibaut

> Alas no ... I'm still searching for a solution.
>
[quoted text clipped - 80 lines]
> > > > > Thanks,
> > > > > Mike
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.