-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathFillInPDFfromDatabase
74 lines (56 loc) · 2.81 KB
/
FillInPDFfromDatabase
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
Function FillInPDFfromDatabase()
'============================================================================
' Name : FillInPDFfromDatabase
' Author : Erica L Ingram
' Copyright : 2019, A Quo Co.
' Call command: Call FillInPDFfromDatabase
' Description : inserts page count & other transcript info into invoice PDF
'============================================================================
On Error GoTo Error_Handler
Dim sKCIInvoicePath As String
Dim joAApp As Acrobat.AcroApp
Dim joAAVDoc As Acrobat.AcroAVDoc
Dim joAPDDoc As Acrobat.AcroPDDoc
Dim joFormApp As AFORMAUTLib.AFormApp
Dim joFormFields As AFORMAUTLib.Fields
Dim joFormField As AFORMAUTLib.Field
Dim sCaseName As String, sContactName As String
'global variable
sCourtDatesID = Forms![NewMainMenu]![ProcessJobSubformNMM].Form![JobNumberField]
sKCIInvoicePath = "T:\In Progress\" & sCourtDatesID & "\WorkingFiles\" & sCourtDatesID & "-KCICompleted.pdf"
FileCopy "T:\Document Generator\templates\KCICompleted.pdf", sKCIInvoicePath
Call GetCaseInfoQDFRecordset 'refresh transcript info
sContactName = sFirstName & " " & sLastName 'made from global variables set from Call GetCaseInfoQDFRecordset
sCaseName = sParty1 & " v. " & sParty2 'made from global variables set from Call GetCaseInfoQDFRecordset
Set joAApp = New AcroApp
Set joAAVDoc = CreateObject("AcroExch.AVDoc")
If joAAVDoc.Open(sKCIInvoicePath, "") Then
joAAVDoc.Maximize (1)
Set joAPDDoc = joAAVDoc.GetPDDoc()
Set joFormApp = CreateObject("AFormAut.App")
Set joFormFields = joFormApp.Fields
For Each joFormField In joFormFields
If joFormField.Name = "Case Name" Then joFormField.Value = sCaseName
If joFormField.Name = "Trial Court No" Then joFormField.Value = sCaseNumber1 'global variable set from Call GetCaseInfoQDFRecordset
If joFormField.Name = "County" Then joFormField.Value = sJurisdiction 'global variable set from Call GetCaseInfoQDFRecordset
If joFormField.Name = "COA Number" Then joFormField.Value = sCaseNumber2 'global variable set from Call GetCaseInfoQDFRecordset
If joFormField.Name = "Servie Requested By" Then joFormField.Value = sContactName
If joFormField.Name = "310amt" Then joFormField.Value = sActualQuantity 'global variable set from Call GetCaseInfoQDFRecordset
If joFormField.Name = "Date" Then joFormField.Value = Date
Next joFormField
sKCIInvoicePath = "T:\In Progress\" & sCourtDatesID & "\WorkingFiles\" & sCourtDatesID & "-KCICompleted1.pdf"
joAPDDoc.Save PDSaveFull, sKCIInvoicePath
joAPDDoc.Close
End If
Exit_Handler:
joAAVDoc.Close True
Set joAPDDoc = Nothing
Set joAAVDoc = Nothing
Set joAApp = Nothing
MsgBox "KCI invoice completed."
Exit Function
Error_Handler:
MsgBox Err.Number & ": " & Err.Description, vbCritical, "Error"
GoTo Exit_Handler
Resume
End Function