Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8950

Re: Digitally signed excel file.

$
0
0

Try this code:

 

integer     li_rc
oleobject xlApp
oleobject     signature
xlApp = Create OLEObject
li_rc = xlApp.ConnectToNewObject( "Excel.Application" )
xlApp.Application.Workbooks.Add()
xlApp.Application.ActiveWorkbook.SaveAs( "SignedDocument.xlsx", 51 )
signature = xlApp.Application.ActiveWorkbook.Signatures.AddNonVisibleSignature ( "{00000000-0000-0000-0000-000000000000}" )
xlApp.Application.Quit()
xlApp.DisconnectObject()
Destroy xlApp

51 is the value for an Excel Workbook.  The file has to be saved in Workbook format for a digital signature to apply.

 

"{00000000-0000-0000-0000-000000000000}" is being passed in as the provider GUID.  Apparently that means prompt the user to select one.

 

What you should see are the following prompts:

 

This one giving a background on digital signatures.  It can be suppressed from displaying again by the user.

prompt1.PNG

This one in which some certificate is selected as the default and the user can change it to another.  The user also needs to give a reason for signing.

prompt2.PNG

You'll see a progress bar indicating that the signature creation process is occurring.  Because I'm using a SmartCard for the signing, I'm prompted for my PIN:

prompt3.PNG

Finally, you'll be notified that the signing is complete.  The end user can suppress that prompt as well.

 

prompt4.PNG

Open up the documents directory and you should find the signed file.


Viewing all articles
Browse latest Browse all 8950

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>