' AUD510 - Transfer PYR510 PQ Files from Districts, Extract Data

Sub AUD510()

' ******************************************************************

' *******************************************************************************************************************

' AUD510 - Transfer PYR510 PQ files from districts, extract data

' with Monarch and export as Excel spreadsheets.

'

' 06/01/07 - Added four additional report files and option for either COE or EXTSVCS for di 12 files

' 01/12/07 - Added two additional report files

' Macro created 04/19/06 by David Doeltz

'

' The following variables are defined as Public at top of NewMacros

' (this) file:

' strGroup, Wkzro, zroWork, pyrFiles and bolCancel

' pyrFiles - Array of the files to be transferred. For PYR320 there can be from 1 to 6. (Note: This array is used

' by other macros; hence the 10 elements)

' Wkzro - String of from 1 to 7 zeroes to pad the numeric portion of the file name

' zroWork - "Constant" string of 7 zeros

' bolCancel - Flag set to True if Cancel button on the form was clicked; no processing takes place

' Wklen - Seven minus the length of the file name entered on the form; the number of zeroes needed to pad the

' file name entered

'

' Files names array (includes path):

' 1 - Transferred PYR510 report file

' 2 - Monarch log file

' 3 - Monarch PYR510A model file

' 4 - Monarch PYR510B model file

' 5 - Exported PYR510A file

' 6 - Exported PYR510B file

' 7 - Monarch Garnishment model file

' 8 - Exported Garnishment file

' *******************************************************************************************************************

Dim openFile, openMod, openFilter, t As Boolean

Dim aryFilnm(8), strSuffix As String

Dim RetVal As Double

On Error GoTo EntExit

Const NEVER_TIME_OUT = 0

Dim LF As String ' Chr$(rcLF) = Chr$(10) = Control-J

Dim CR As String ' Chr$(rcCR) = Chr$(13) = Control-M

Dim ESC As String ' Chr$(rcESC) = Chr$(27) = Control-[

LF = Chr$(rcLF)

CR = Chr$(rcCR)

ESC = Chr$(rcESC)

zroWork = "0000000"

bolGarnish = False

With Session

' At a menu, simulate typing "FT" and pressing the Enter key

.Transmit "FT"

.TransmitTerminalKey rcHpEnterKey

.WaitForString LF & " finished, enter EXIT to terminate." & CR & LF, NEVER_TIME_OUT, rcAllowKeystrokes

.WaitForHostTrigger

EntFil:

On Error GoTo EntExit

' Show the download dialog form

frmAud510.Show

' If no PQ file number is entered or Cancel was clicked, do nothing and exit the macro

If bolCancel = True Then

GoTo EntExit

End If

Select Case strGroup

Case "BONNYDOO"

strSuffix = "01"

Case "HAPPYVAL"

strSuffix = "02"

Case "LIVEOAK"

strSuffix = "03"

Case "MOUNTAIN"

strSuffix = "04"

Case "PACIFIC"

strSuffix = "05"

Case "SCOTTSVA"

strSuffix = "07"

Case "SOQUEL"

strSuffix = "08"

Case "SANLOREN"

strSuffix = "11"

Case "COE", "EXTSVCS"

strSuffix = "12"

Case "SCCITY"

strSuffix = "14"

Case "PAJARO"

strSuffix = "20"

End Select

' Set the file names

aryFilnm(1) = "C:\Audit510\Reports\PYR510" & strSuffix & ".PRN"

aryFilnm(2) = "C:\Audit510\Audit510.log"

aryFilnm(3) = "C:\Audit510\Models\Audit510-1.mod"

aryFilnm(4) = "C:\Audit510\Models\Audit510-2.mod"

aryFilnm(5) = "C:\Audit510\Export\AUD510" & strSuffix & "-1.XLS"

aryFilnm(6) = "C:\Audit510\Export\AUD510" & strSuffix & "-2.XLS"

aryFilnm(7) = "C:\Audit510\Models\Garnishments.xmod"

aryFilnm(8) = "C:\Audit510\Export\Garnishments.XLS"

On Error GoTo BadFil

If pyrFiles(1) > "" Then

.WRQReceiveFile aryFilnm(1), pyrFiles(1), rcASCII, rcOverwrite

End If

If pyrFiles(2) > "" Then

.WRQReceiveFile aryFilnm(1), pyrFiles(2), rcASCII, rcAppend

End If

If pyrFiles(3) > "" Then

.WRQReceiveFile aryFilnm(1), pyrFiles(3), rcASCII, rcAppend

End If

If pyrFiles(4) > "" Then

.WRQReceiveFile aryFilnm(1), pyrFiles(4), rcASCII, rcAppend

End If

If pyrFiles(5) > "" Then

.WRQReceiveFile aryFilnm(1), pyrFiles(5), rcASCII, rcAppend

End If

If pyrFiles(6) > "" Then

.WRQReceiveFile aryFilnm(1), pyrFiles(6), rcASCII, rcAppend

End If

If pyrFiles(7) > "" Then

.WRQReceiveFile aryFilnm(1), pyrFiles(7), rcASCII, rcAppend

End If

If pyrFiles(8) > "" Then

.WRQReceiveFile aryFilnm(1), pyrFiles(8), rcASCII, rcAppend

End If

' Start of Monarch code

Set MonarchObj = GetObject("", "monarch32")

If MonarchObj Is Nothing Then

Set MonarchObj = CreateObject("Monarch32")

End If

If bolGarnish = False Then

t = MonarchObj.SetLogFile(aryFilnm(2), False)

openFile = MonarchObj.SetReportFile(aryFilnm(1), False)

If openFile = True Then

openMod = MonarchObj.SetModelFile(aryFilnm(3))

If openMod = True Then

MonarchObj.CurrentFilter = ""

MonarchObj.ExportTable (aryFilnm(5))

End If

End If

openFile = MonarchObj.SetReportFile(aryFilnm(1), False)

If openFile = True Then

openMod = MonarchObj.SetModelFile(aryFilnm(4))

If openMod = True Then

MonarchObj.CurrentFilter = ""

MonarchObj.ExportTable (aryFilnm(6))

End If

End If

Else

t = MonarchObj.SetLogFile(aryFilnm(2), False)

openFile = MonarchObj.SetReportFile(aryFilnm(1), False)

If openFile = True Then

openMod = MonarchObj.SetModelFile(aryFilnm(7))

If openMod = True Then

MonarchObj.CurrentFilter = ""

MonarchObj.ExportTable (aryFilnm(8))

End If

End If

End If

MonarchObj.CloseAllDocuments

MonarchObj.Exit

' End of Monarch code

EntExit:

' After the download is complete, simulate typing "Exit" and pressing Return

.Transmit "EXIT" & CR

.StatusBar = "Waiting for Prompt: :"

.WaitForString ESC & "b", NEVER_TIME_OUT, rcAllowKeystrokes

.WaitForHostTrigger

.StatusBar = ""

.CapsLock = False

Exit Sub

BadFil:

MsgBox "No such file; is the district correct?", 16, "File Not Found"

GoTo EntFil

End With

End Sub