on 07-03-2014 9:35 AM
Dear All,
Can it be possible to digitally signed MS Excel file &
protect (Read-only) using powerbuilder12.5 classic?
Thanks & e-Regards
Avishek
What do you mean by "digitally sign"? If you mean something like the following, then once you know how to do it via a Macro then you can create OLE Automation scripts to do the same thing the macro does.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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.
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:
Finally, you'll be notified that the signing is complete. The end user can suppress that prompt as well.
Open up the documents directory and you should find the signed file.
Dear Bruce,
Extremely thanks for your guidance & help.
But I have few questions & requirement clarification.
Questions:-
"{00000000-0000-0000-0000-000000000000}" is being
passed in as the provider GUID. You want to mean the serial no of the
signature?
During run the code I found
the following problem?
Requirement
clarification
My PB
application generate a excel file, I want to self signed this excel file.
Following is
the parameter of my signature file.
Thanks & e-Regards
Avishek
The GUID is the ID of the signature provider. See the following:
SignatureSet.AddNonVisibleSignature Method
As for the error you are getting, you'll have to do some debugging. Did the ConnectToNewObject work? Did saving the file in WorkBook format work? If those failed, you won't be able to sign the file.
User | Count |
---|---|
84 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.