Code:
Public Sub AddSigBoxes()Dim App As Object, AVdoc As Object, AForm As Object, Cnt As Integer, Y As Integer, X As Integer
Dim TODA As String, FNames As String, Rev As String, FT As String, Path As String, js As String, js1 As String, js2 As String, Cord As String, Cord1 As String, Cord2 As String
On Error GoTo Err_Handler
Cnt = DCount("SLeg", "[QryTAR]") - 1
TODA = DLookup("[TODA]", "[QryTAR]")
FNames = DLookup("[FNames]", "[QryTAR]")
Rev = DLookup("[Type]", "[QryTAR]")
FT = DLookup("[FTCode]", "[QryTAR]")
X = 174 - Cnt * 15
Y = 134 - Cnt * 15
Cord = "[26," & X & ",217," & Y & "]"
Cord1 = "[267," & X & ",483," & Y & "]"
Cord2 = "[534," & X & ",750," & Y & "]"
Set App = CreateObject("Acroexch.app")
App.Hide
Set AVdoc = CreateObject("AcroExch.AVDoc")
Set AForm = CreateObject("AFormAut.App")
Path = "C:\TEMP\" & "0009TAR(" & FNames & ")(" & TODA & ")(" & [FT] & ")" & Rev & "_" & TOD & ".pdf"
If AVdoc.Open(Path, "") Then
js = "f = this.addField(""SignatureField1"", ""signature"", 0, " & Cord & ");" & "f.value = ""TPOC""; " & " f.flatten" ' [26,174,217,134]
AForm.Fields.ExecuteThisJavaScript js
js1 = "f = this.addField(""SignatureField2"", ""signature"", 0, " & Cord1 & ");" & "f.value = ""PM""; " & "f.flatten" ' [267,174,483,134]
AForm.Fields.ExecuteThisJavaScript js1
js2 = "f = this.addField(""SignatureField3"", ""signature"", 0, " & Cord2 & ");" & "f.value = ""COR""; " & "f.flatten" ' [534,174,750,134]
AForm.Fields.ExecuteThisJavaScript js2
Path = Left(Path, Len(Path) - 4) & "s.pdf"
Set AForm = AVdoc.GetPDDoc
AForm.Save PDSaveFull, Path
AVdoc.Close False
End If
App.Exit
Set App = Nothing
Set AVdoc = Nothing
Set AForm = Nothing
Path = ""
Exit_Proc:
Exit Sub
Err_Handler:
MsgBox "Error: " & Err.Number & " - " & Err.Description
Resume Exit_Proc
End Sub