chipsworld
Board Regular
- Joined
- May 23, 2019
- Messages
- 164
- Office Version
- 365
Hi all,
I tried to ask from the original post by John_w, but am guessing that no one is watching that so...here goes.
This code was originally posted by John_w back in 2019, and works beautifully, but had modification questions...
How could this be modified to allow for two (or more) signature blocks to be placed on the same PDF Form?
I have been playing with it, but having no luck so far...
Any input would be very welcome...
I tried to ask from the original post by John_w, but am guessing that no one is watching that so...here goes.
This code was originally posted by John_w back in 2019, and works beautifully, but had modification questions...
How could this be modified to allow for two (or more) signature blocks to be placed on the same PDF Form?
I have been playing with it, but having no luck so far...
Any input would be very welcome...
VBA Code:
Public Sub Save_Sheet_As_PDF_Add_Signature_Field()
Worksheets("Calc Sheet").Unprotect Password:=""
Dim PDDoc As Object
Dim AVDoc As Object
Dim JSO As Object
Dim formField As Object
Dim formField2 As Object
Dim inputPDFfile As String, outputPDFfile As String
Dim coords() As Variant
Dim coords2() As Variant
Dim filnam As String
filnam = Worksheets("Formulas").Range("V5") & " - " & Worksheets("Formulas").Range("V4") & " - " & Format(Date, "dd MMM yy")
' coordinates for QC signature
Const BOTTOM_LEFT_X = 315
Const BOTTOM_LEFT_Y = 50
Const WIDTH = 320
Const HEIGHT = 30
'Coordinates specifying position and size of the signature field's bounding rectangle, with origin (0,0) at bottom left of page,
'in the following order: top-left x, top-left y, bottom-right x and bottom-right y.
coords = Array(BOTTOM_LEFT_X, BOTTOM_LEFT_Y + HEIGHT, BOTTOM_LEFT_X + WIDTH, BOTTOM_LEFT_Y)
With ActiveSheet
inputPDFfile = ThisWorkbook.Path & "\Calc Sheets\delete\" & filnam & ".pdf"
outputPDFfile = ThisWorkbook.Path & "\Calc Sheets\" & filnam & " - " & " WSF.pdf"
.ExportAsFixedFormat Type:=xlTypePDF, Filename:=inputPDFfile, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
End With
Set PDDoc = CreateObject("AcroExch.PDDoc")
Set AVDoc = CreateObject("AcroExch.AVDoc")
If PDDoc.Open(inputPDFfile) Then
Set JSO = PDDoc.GetJSObject
Set formField = JSO.AddField("SignatureField", "signature", 0, coords) '0 = 1st page
formField.StrokeColor = JSO.Color.Black 'StrokeColor sets the border and text colours of the field
If PDDoc.Save(1, outputPDFfile) Then
PDDoc.Close
AVDoc.Open outputPDFfile, vbNullString
AVDoc.BringToFront
AVDoc.Close True
Else
MsgBox "Unable to save: " & outputPDFfile
End If
End If
Kill inputPDFfile
Worksheets("Calc Sheet").Protect Password:=""
End Sub