Do I need a vba-access code to insert digital signature (digital certificate) in a report, Someone help!? (1 Viewer)

clebergyyn

New member
Local time
Yesterday, 23:36
Joined
Feb 16, 2017
Messages
25
Good morning Good Night! I need to develop a code in Access-vba to sign a report (medical prescription) with A1 digital certificate (Digital signature with certificate). Each user (doctor) will have their digital certificate installed on windows to digitally sign the report. Can anyone help?
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 23:36
Joined
Oct 29, 2018
Messages
21,489
Hi. Just thinking out loud, but I wonder if that would require an ActiveX control, if one exists.

Sent from phone...
 

clebergyyn

New member
Local time
Yesterday, 23:36
Joined
Feb 16, 2017
Messages
25
I thought about this, ActiveX control, but I also have this doubt. I've seen people talk about microsoft's CAPICOM dll, I couldn't install it.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 01:36
Joined
Feb 28, 2001
Messages
27,217
A digital signature usually involves encryption code where you pass in a key and a file to get a digital hash. This topic has come up before. There are some threads that MAY have useful links.



(The above link came from this thread:)

 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 14:36
Joined
May 7, 2009
Messages
19,247
in short, we don't know what is that!?
maybe you can ask your vendor if it can be manipulated through VBA (password login and signing docs, etc.).
 

June7

AWF VIP
Local time
Yesterday, 22:36
Joined
Mar 9, 2014
Messages
5,488
An Access report is not an independent file. It is a dynamically rendered object within Access application. As already noted, likely best option is export to PDF and somehow modify that file to accommodate digital signature. Another option is merging Access data with Word document and applying signature there.
 

clebergyyn

New member
Local time
Yesterday, 23:36
Joined
Feb 16, 2017
Messages
25
If you have a function to sign a pdf, by access-vba, it also helps me.
 

clebergyyn

New member
Local time
Yesterday, 23:36
Joined
Feb 16, 2017
Messages
25

sonic8

AWF VIP
Local time
Today, 08:36
Joined
Oct 27, 2015
Messages
998
Excel vba is different from Access vba.
It isn't. VBA is the same in all VBA enabled application. Only the object libraries, which are available by default, differ.
The task of signing a PDF file requires external libraries containing automation objects supporting this task (e.g. AcroPDDoc in this case). You need to install such a library. I believe the example from the link uses Adobe's Acrobat SDK.
 

June7

AWF VIP
Local time
Yesterday, 22:36
Joined
Mar 9, 2014
Messages
5,488
Not that much different. Only thing I couldn't get to work in Excel VBA that worked in Access VBA was Nz() function. Even a query object that used Nz() had to be modified. Maybe I didn't have a necessary library referenced in Excel.

I have used in Access VBA:
Code:
'Relies on the Adobe Acrobat 6.0 Type Library
Dim pdfDoc As Acrobat.AcroPDDoc
Set pdfDoc = New Acrobat.AcroPDDoc
Dim pdfDoc2 As Acrobat.AcroPDDoc
Set pdfDoc2 = New Acrobat.AcroPDDoc
and
Code:
Dim objCAcroPDDocDestination As Object
Dim objCAcroPDDocSource As Object
Set objCAcroPDDocDestination = CreateObject("AcroExch.PDDoc")
Set objCAcroPDDocSource = CreateObject("AcroExch.PDDoc")
I had Adobe Acrobat Pro installed when I developed that code. Don't have any more and code won't run.
 
Last edited:

clebergyyn

New member
Local time
Yesterday, 23:36
Joined
Feb 16, 2017
Messages
25
Not that much different. Only thing I couldn't get to work in Excel VBA that worked in Access VBA was Nz() function. Even a query object that used Nz() had to be modified. Maybe I didn't have a necessary library referenced in Excel.

I have used in Access VBA:
Code:
'Relies on the Adobe Acrobat 6.0 Type Library
Dim pdfDoc As Acrobat.AcroPDDoc
Set pdfDoc = New Acrobat.AcroPDDoc
Dim pdfDoc2 As Acrobat.AcroPDDoc
Set pdfDoc2 = New Acrobat.AcroPDDoc
and
Code:
Dim objCAcroPDDocDestination As Object
Dim objCAcroPDDocSource As Object
Set objCAcroPDDocDestination = CreateObject("AcroExch.PDDoc")
Set objCAcroPDDocSource = CreateObject("AcroExch.PDDoc")
I had Adobe Acrobat Pro installed when I developed that code. Don't have any more and code won't run.
Thanks. Don't have the complete code in vba-access? To insert digital signature in pdf, by Access-vba
 

June7

AWF VIP
Local time
Yesterday, 22:36
Joined
Mar 9, 2014
Messages
5,488
No, I do not. I have done other operations with PDF objects (merge, extract) but no signature. The Excel VBA should work in Access. Unfortunately, I cannot test.
 

clebergyyn

New member
Local time
Yesterday, 23:36
Joined
Feb 16, 2017
Messages
25
No, I do not. I have done other operations with PDF objects (merge, extract) but no signature. The Excel VBA should work in Access. Unfortunately, I cannot test.

Good morning Good Night! Can someone help me to implement this code below, applying the suggestion of "June7" above, for this code to work in Vba-Access. Because this code was made for Excel, and it doesn't work in Access-vba.

Code:
Sub SignPDF()
On Error GoTo Err_Handler
Dim pdfPDDoc As New AcroPDDoc, oJS As Object, oSign As Object, oPpklite As Object, oFields As Object
Dim strFName1 As String, strFName2 As String, strSignFName As String
Dim oSignInfo As Object, strSecInfo As String
Dim oParam As Parameter
    
   strSignFName = "C:\mySignature.pfx"
   strFName1 = "C:\myPdf.pdf"
   strFName2 = "C:\myPdf-signed.pdf"

   Set pdfPDDoc = CreateObject("AcroExch.PDDoc")
    
   If pdfPDDoc.Open(strFName1) Then
      Set oJS = pdfPDDoc.GetJSObject
      
      Set oFields = oJS.AddField("SignatureField", "signature", 0, Array(350, 800, 500, 750))
      Set oSign = oJS.GetField("SignatureField")
      
      Set oPpklite = oJS.security.getHandler("Adobe.PPKLite", True)
      oPpklite.login "{'myPasswd', '" & strSignFName & "'}"
      oSign.signatureSign oPpklite
      
      pdfPDDoc.Save 1, strFName2
      oPpklite.logout
   End If
  
Exit_Proc:
    Exit Sub
        
Err_Handler:
    MsgBox "In test" & vbCrLf & Err.Number & "--" & Err.Description
    Resume Exit_Proc
End Sub
 

GPGeorge

George Hepworth
Local time
Yesterday, 23:36
Joined
Nov 25, 2004
Messages
1,899
"...Because this code was made for Excel, and it doesn't work in Access-vba...."

Sometimes we can guess what it means when someone says, "...it doesn't work...", but most of the time, we are less successful. The solution for that problem is for you to explain what it actually means, to avoid the guesswork.
 

clebergyyn

New member
Local time
Yesterday, 23:36
Joined
Feb 16, 2017
Messages
25
"...Because this code was made for Excel, and it doesn't work in Access-vba...."

Sometimes we can guess what it means when someone says, "...it doesn't work...", but most of the time, we are less successful. The solution for that problem is for you to explain what it actually means, to avoid the guesswork.
...is an Access-vba code to "digitally sign" (with Official Digital Certificate) a pdf file. This code for Excel-Vba that I put helps as it has similarity with Access-vba. First we install a digital signature (digital certificate) in Windows. Then we use it to sign documents as pdf. The code I need is for this. Hope someone can help. Thank you very much in advance.
 

Users who are viewing this thread

Top Bottom