cancel
Showing results for 
Search instead for 
Did you mean: 

Digitally signed excel file.

Former Member
0 Kudos

Dear All,

Can it be possible to digitally signed MS Excel file &
protect (Read-only) using powerbuilder12.5 classic?

Thanks & e-Regards

Avishek

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member190719
Active Contributor
0 Kudos

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.

Former Member
0 Kudos

Dear Bruce,

Thank you for your answer. For your ease I attached the screen shot of digital signature.

That I want to create using powerbuilder classic code. I am unable to see the youtube link for my network.

Thanks

Avishek


former_member190719
Active Contributor
0 Kudos

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.

Former Member
0 Kudos

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

former_member190719
Active Contributor
0 Kudos

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.