Dear all,
first point: sorry for the grammar, english isn't my native language.
Now my problem: I do have a Excel sheet from which a pdf is created with a macro. There's also a field for signature being added to the pdf. I would like to create 2 drop down menus in the pdf, so u can tell, which rank the person signing has. But I cant find any code to create a drop down menü. Can anyone help me? Thanks in advance. Following is the code I'm currently using.
Public Sub TESTSave_Sheet_As_PDF_Add_2_Signature_Fields()
Dim PDDoc As Object
Dim AVDoc As Object
Dim JSO As Object
Dim formField As Object
Dim inputPDFfile As String, outputPDFfile As String
Dim coords() As Variant
Const TOP_LEFT_X = 51
Const TOP_LEFT_Y = 197
Const WIDTH = 161
Const HEIGHT = 63
With ActiveSheet
.Range("F1").Value = "Created " & Now
inputPDFfile = ThisWorkbook.Path & "\" & .Name & ".pdf"
outputPDFfile = ThisWorkbook.Path & "\" & .Name & " WITH 2 SIGNATURE FIELDS.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
'The 4th argument to JSO.addField is an array of coordinates specifying the 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.
'1st signature field
coords = Array(TOP_LEFT_X, TOP_LEFT_Y, TOP_LEFT_X + WIDTH, TOP_LEFT_Y - HEIGHT)
Set formField = JSO.addField("SignatureField1", "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
MsgBox "Created " & outputPDFfile
AVDoc.Close False
Else
MsgBox "Unable to save " & outputPDFfile
End If
End If
End Sub
first point: sorry for the grammar, english isn't my native language.
Now my problem: I do have a Excel sheet from which a pdf is created with a macro. There's also a field for signature being added to the pdf. I would like to create 2 drop down menus in the pdf, so u can tell, which rank the person signing has. But I cant find any code to create a drop down menü. Can anyone help me? Thanks in advance. Following is the code I'm currently using.
Public Sub TESTSave_Sheet_As_PDF_Add_2_Signature_Fields()
Dim PDDoc As Object
Dim AVDoc As Object
Dim JSO As Object
Dim formField As Object
Dim inputPDFfile As String, outputPDFfile As String
Dim coords() As Variant
Const TOP_LEFT_X = 51
Const TOP_LEFT_Y = 197
Const WIDTH = 161
Const HEIGHT = 63
With ActiveSheet
.Range("F1").Value = "Created " & Now
inputPDFfile = ThisWorkbook.Path & "\" & .Name & ".pdf"
outputPDFfile = ThisWorkbook.Path & "\" & .Name & " WITH 2 SIGNATURE FIELDS.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
'The 4th argument to JSO.addField is an array of coordinates specifying the 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.
'1st signature field
coords = Array(TOP_LEFT_X, TOP_LEFT_Y, TOP_LEFT_X + WIDTH, TOP_LEFT_Y - HEIGHT)
Set formField = JSO.addField("SignatureField1", "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
MsgBox "Created " & outputPDFfile
AVDoc.Close False
Else
MsgBox "Unable to save " & outputPDFfile
End If
End If
End Sub