Dim $accessApp
$thismo = @monthno -1
IF $thismo = 0
$month = "12"
ELSE
IF $thismo > 9
$month = CSTR($thismo)
ELSE
$month = "0" + CSTR($thismo)
ENDIF
ENDIF
$year = IIf(@MONTHNO = 1, @YEAR -1, @YEAR)
;open log file
IF Open(2, "\\server\folder\monthlylog$month.txt",5) = 0
$w = WriteLine( 2 , "allowA.kix started at " +@DATE + " - " + @TIME + @CRLF )
ELSE
BEEP
? "Error opening log file: [" + @ERROR + "]"
sleep 5
EXIT
ENDIF
$accessApp = CreateObject("Access.Application")
;$accessApp.visible = 1
$accessApp.OpenCurrentDatabase("\\Server\folder\allow.mdb")
$accessApp.DoCmd.RunMacro("A")
$accessApp.DisplayAlerts = 0
$accessApp.Quit
$accessApp = 0
If Not Exist("\\server\folder\allow.xls")
$w = WriteLine( 2 , "Error: Initial file not found. Exiting..." + @CRLF )
$w = WriteLine( 2 , "allowa.kix finished at " +@DATE + " - " + @TIME + @CRLF )
$w = WriteLine( 2 , " " + @CRLF )
$ = Close (2)
Exit 1
EndIf
; open excel file allowable created by Access macro above
; format and save with correct name
$app = CreateObject("Excel.Application")
;$app.visible = 1
;Create the Workbooks object
$wbs = $app.Workbooks
sleep 5
$rc = $wbs.Open("\\server\folder\allow.xls")
$app.Range("A1:L1").Font.Bold = 1
$app.Range("I1").Entirecolumn.NumberFormat = "$#,##0.00"
$app.Range("K1").Entirecolumn.NumberFormat = "$#,##0.00"
$app.Range("L1").Entirecolumn.NumberFormat = "$#,##0.00"
$app.Range("A1:L1").EntireColumn.AutoFit
$filename = "\\server\folder\A-$year-$month.xls"
$app.ActiveWorkbook.SaveAs("$filename",-4143)
$rc = $wbs.Open("\\server\folder\missing.xls")
$app.Range("A1:K1").Font.Bold = 1
$app.Range("H1").Entirecolumn.NumberFormat = "$#,##0.00"
$app.Range("I1").Entirecolumn.NumberFormat = "$#,##0.00"
$app.Range("J1").Entirecolumn.NumberFormat = "$#,##0.00"
$app.Range("A1:K1").EntireColumn.AutoFit
$filename = "\\server\folder\Amissing-$year-$month.xls"
$app.ActiveWorkbook.SaveAs("$filename",-4143)
Del "\\server\folder\allow.xls"
Del "\\server\folder\missing.xls"
$wbs.Close
$wbs = 0
$app.DisplayAlerts = 0
$app.Quit
$app = 0
$w = WriteLine( 2 , "allowa.kix finished at " +@DATE + " - " + @TIME + @CRLF )
$w = WriteLine( 2 , " " + Chr(13) + Chr(10) )
$ = Close (2)