asked on
Public Function PDFdatecheck() As Boolean
SDdrive = Forms("frmFirewall").txtSDdriveLetter.Value
'-----CHECK PDF DATE-----'
'IAC objects
'DoCmd.Hourglass True
Dim gAvDoc As Object
'variables
Dim Resp 'For message box responses
Dim gPDFPath As String
Dim sText1 As String 'String to search for
Dim sText2 As String 'String to search for
Dim sText3 As String 'String to search for
Dim sText4 As String 'String to search for
Dim sText5 As String 'String to search for
Dim sText6 As String 'String to search for
Dim sText7 As String 'String to search for
Dim sText8 As String 'String to search for
Dim sText9 As String 'String to search for
Dim sText10 As String 'String to search for
Dim sText11 As String 'String to search for
Dim sText12 As String 'String to search for
Dim sText13 As String 'String to search for
Dim sStr As String 'Message string
Dim foundText1 As Integer 'Holds return value from "FindText" method
Dim foundText2 As Integer 'Holds return value from "FindText" method
Dim foundText3 As Integer 'Holds return value from "FindText" method
Dim foundText4 As Integer 'Holds return value from "FindText" method
Dim foundText5 As Integer 'Holds return value from "FindText" method
Dim foundText6 As Integer 'Holds return value from "FindText" method
Dim foundText7 As Integer 'Holds return value from "FindText" method
Dim foundText8 As Integer 'Holds return value from "FindText" method
Dim foundText9 As Integer 'Holds return value from "FindText" method
Dim foundText10 As Integer 'Holds return value from "FindText" method
Dim foundText11 As Integer 'Holds return value from "FindText" method
Dim foundText12 As Integer 'Holds return value from "FindText" method
Dim foundText13 As Integer 'Holds return value from "FindText" method
Dim Respi
Dim Path As String
'hard coding for a PDF to open, it can be changed when needed.
'Path = SDdrive & ":\aLXE-Pricing\Reunion\Branch300.pdf"
gPDFPath = filePath
'Initialize Acrobat by creating App object
Set gApp = CreateObject("AcroExch.App")
gApp.Hide
'Set AVDoc object
Set gAvDoc = CreateObject("AcroExch.AVDoc")
' open the PDF
If gAvDoc.Open(gPDFPath, "") Then
sText1 = Format(Date, "mmmm d, yyyy") 'enter your searchstring here
sText2 = Format(Date, "mmm-d-yyyy") 'enter your searchstring here
sText3 = Format(Date, "mm/dd/yy") 'enter your searchstring here
sText4 = Format(Date, "mm/dd/yyyy") 'enter your searchstring here
sText5 = Format(Date, "m/d/yyyy") 'enter your searchstring here
sText6 = Format(Date, "m/d/yy") 'enter your searchstring here
sText7 = Format(Date, "mm_dd_yyyy") 'enter your searchstring here
sText8 = Format(Date, "dddd, mmmm dd, yyyy") 'enter your searchstring here
sText9 = Format(Date, "mmm-dd-yy") 'enter your searchstring here
sText10 = Format(Date, "mmmm dd, yyyy") 'enter your searchstring here
sText11 = Format(Date, "mmm dd, yyyy") 'enter your searchstring here
sText12 = Format(Date, "mmm d, yyyy") 'enter your searchstring here
sText13 = Format(Date, "d-mmm-yy") 'enter your searchstring here
'FindText params: StringToSearchFor, caseSensitive (1 or 0), WholeWords (1 or 0), ResetSearchToBeginOfDocument (1 or 0)
foundText1 = gAvDoc.FindText(sText1, 1, 0, 1) 'Returns -1 if found, 0 otherwise
foundText2 = gAvDoc.FindText(sText2, 1, 0, 1) 'Returns -1 if found, 0 otherwise
foundText3 = gAvDoc.FindText(sText3, 1, 0, 1) 'Returns -1 if found, 0 otherwise
foundText4 = gAvDoc.FindText(sText4, 1, 0, 1) 'Returns -1 if found, 0 otherwise
foundText5 = gAvDoc.FindText(sText5, 1, 0, 1) 'Returns -1 if found, 0 otherwise
foundText6 = gAvDoc.FindText(sText6, 1, 0, 1) 'Returns -1 if found, 0 otherwise
foundText7 = gAvDoc.FindText(sText7, 1, 0, 1) 'Returns -1 if found, 0 otherwise
foundText8 = gAvDoc.FindText(sText8, 1, 0, 1) 'Returns -1 if found, 0 otherwise
foundText9 = gAvDoc.FindText(sText9, 1, 0, 1) 'Returns -1 if found, 0 otherwise
foundText10 = gAvDoc.FindText(sText10, 1, 0, 1) 'Returns -1 if found, 0 otherwise
foundText11 = gAvDoc.FindText(sText11, 1, 0, 1) 'Returns -1 if found, 0 otherwise
foundText12 = gAvDoc.FindText(sText12, 1, 0, 1) 'Returns -1 if found, 0 otherwise
foundText13 = gAvDoc.FindText(sText13, 1, 0, 1) 'Returns -1 if found, 0 otherwise
Else
' if failed, show error message
'Resp = MsgBox("Cannot open" & gPDFPath, vbOKOnly)
PDFdatecheck = True
gAvDoc.BringToFront
Sleep 2000
SendKeys ("^q"), True 'exit document
Sleep 1500
On Error Resume Next
gApp.Exit
Set gAvDoc = Nothing
Set gApp = Nothing
'numberlock
Exit Function
End If
If foundText1 = -1 Or foundText2 = -1 Or foundText3 = -1 Or foundText4 = -1 Or foundText5 = -1 Or foundText6 = -1 Or foundText7 = -1 Or foundText8 = -1 Or foundText9 = -1 Or foundText10 = -1 Or foundText11 = -1 Or foundText12 = -1 Or foundText13 = -1 Then
'compose a message
'sStr = "Rates are Current"
'Resp = MsgBox(sStr, vbOKOnly)
gAvDoc.BringToFront
Sleep 2000
SendKeys ("^q"), True 'exit document
Sleep 1500
On Error Resume Next
gApp.Exit
Set gAvDoc = Nothing
Set gApp = Nothing
'SendKeys ("{ENTER}"), True 'exit document
Else
' if failed, show error message
'Resp = MsgBox("Today's Rates Not Available Yet", vbOKOnly)
PDFdatecheck = True
gAvDoc.BringToFront
Sleep 2000
SendKeys ("^q"), True 'exit document
Sleep 1500
On Error Resume Next
gApp.Exit
Set gAvDoc = Nothing
Set gApp = Nothing
End If
End Function