; Below is the final solution to get the suckers (suckers being $cmonth and $lmonth)
; to work in the run command down in the Case statement.
; Gee, what a goat rope this has been ...
$cmonth4t = $cmonth
$cmonth = Chr(34) + $cmonth + Chr(34)
$lmonth = Chr(34) + $lmonth + Chr(34)
$Today = @date
$f = GetFileTime($cmonth4t)
$meprs = SubStr($f,1,10)
?
? "Current Month Variable"
? $cmonth4t
?
?
? "GetFileTime: " + $f
?
? "File time on Current Month: "
? "($meprs) - " + $meprs
?
? "Current date string: "
? $Today
Sleep 15
Select
Case Exist ($cmonth) ; This is the default current month condition
? "In current month select Logic ..."
If $meprs < $Today
Run 'cmd /c $cmonth'
EndIf
Case Exist ($newmeprs) ; This is the New Month condition
Copy $newmeprs $cmonth
$excel = CreateObject("excel.application")
$excel.visible = 0
$excel.displayalerts = 0
$book = $excel.workbooks.Open($lmonth)
$excel.Sheets($lmonsname).activate
$vwc = $excel.activesheet.columns(8).rows(3).value
$vocc = $excel.activesheet.columns(8).rows(4).value
$vskill = $excel.activesheet.columns(14).rows(3).value
$vdesc = $excel.activesheet.columns(13).rows(4).value
$vwca = $excel.activesheet.columns(18).rows(4).value
$vmtfd = $excel.activesheet.columns(18).rows(5).value
$vacct1 = $excel.activesheet.columns(8).rows(11).value
$vacct2 = $excel.activesheet.columns(9).rows(11).value
$vacct3 = $excel.activesheet.columns(10).rows(11).value
$vacct4 = $excel.activesheet.columns(11).rows(11).value
$vacct5 = $excel.activesheet.columns(12).rows(11).value
$vacct6 = $excel.activesheet.columns(13).rows(11).value
$vacct7 = $excel.activesheet.columns(14).rows(11).value
$vacct8 = $excel.activesheet.columns(15).rows(11).value
$vacct9 = $excel.activesheet.columns(16).rows(11).value
$vacct10 = $excel.activesheet.columns(17).rows(11).value
$excel.visible = 0
$excel.Quit()
$excel = 0
$excel = CreateObject("excel.application")
$excel.visible = 0
$excel.displayalerts = 0
$book = $excel.workbooks.Open($cmonth)
;activate the sheet with current month's short name, i.e., if September 20005 then
;the short name will be Sep 05. Develop in variable named $TabName
$excel.Sheets($Tabname).activate
$excel.ActiveSheet.Name = $Tabname
$Excel.ActiveSheet.Columns(8).Rows(2).Value = @fullname
$excel.activesheet.columns(8).rows(3).value = $vwc
$excel.activesheet.columns(8).rows(4).value = $vocc
$excel.activesheet.columns(14).rows(3).value = $vskill ; - old code
$excel.activesheet.columns(13).rows(4).value = $vdesc
$excel.activesheet.columns(18).rows(4).value = $vwca
$excel.activesheet.columns(18).rows(5).value = $vmtfd
$excel.activesheet.columns(8).rows(6).value = Left(@month,3)
$excel.activesheet.columns(8).rows(7).value = @year
$excel.activesheet.columns(8).rows(11).value = $vacct1
$excel.activesheet.columns(9).rows(11).value = $vacct2
$excel.activesheet.columns(10).rows(11).value = $vacct3
$excel.activesheet.columns(11).rows(11).value = $vacct4
$excel.activesheet.columns(12).rows(11).value = $vacct5
$excel.activesheet.columns(13).rows(11).value = $vacct6
$excel.activesheet.columns(14).rows(11).value = $vacct7
$excel.activesheet.columns(15).rows(11).value = $vacct8
$excel.activesheet.columns(16).rows(11).value = $vacct9
$excel.activesheet.columns(17).rows(11).value = $vacct10
$ = $Excel.ActiveSheet.SaveAs($cmonth)
$excel.visible = 0
$excel.Quit()
$excel = 0
; Let's see if the below statement opens the spreadsheet
; run 'cmd /c $cmonth'
If Exist ($lmonth)
Run 'cmd /c $lmonth'
Else
Run 'cmd /c $cmonth'
EndIf
Case Exist ($lmonth) ; Removed the = 1, not sure why this case exists?
Run 'cmd /c $lmonth'
Case 1
? "You are in the default case condition, nothing happened."
? "Please contact the Helpdesk at 7-9966 and report a MEPRS PopUp failure"
? "Tell the Helpdesk technician that error MPU-999 occurred."
?
? "This message will disappear in 20 seconds."
Sleep 15
EndSelect