#include #include #include #include #include #include #include $variable1 = TimerInit AutoItSetOption ( "WinTitleMatchMode",2) AutoItSetOption ( 'MouseCoordMode',0) $reportname = StringSplit(" ","") $reportname[0] = "Reports" $reportname[1] = "1 SO (Outstanding Order)" $reportname[2] = "2 PRP Prod" $reportname[3] = "3 PRP Pur" $reportname[4] = "4 Prod Claim" $reportname[5] = "5 Pur Claim" $reportname[6] = "6 Buy to whs " $reportname[7] = "7 PRP whs (W2P and P2W)" $reportname[8] = "8 Proj to Proj" $reportname[9] = "9 Trigger list " $reportname[10]= "10 Sub con claim" $reportname[11]= "11 INV Plan Pur Orders" $reportname[12]= "12 INV Plan Prod Orders" $reportname[13]= "13 ITM data" $reportname[14]= "14 Material Issue Analysis" $reportname[15]= "15 IQA-LOC" $reportname[16]= "16 ILC INV data" $reportname[17]= "17 Economic stock" $reportname[18]= "18 Pro Closing Monitoring Report_ All" $reportname[19]= "19 Pro Closing Report_ All" $reportname[20]= "20 Pending IQA" $reportname[21]= "21 RUN All Reports from 1 to 20(except 3 and 5)" $reportname[22]= "22 Range PRP Purchase" $reportname[23]= "23 Range Economic stock" $reportname[24]= "24 Compile PRP Purchase and Economic stock" $reportname[25]= "25 Delete.xls files inside Auto download folder" $reportname[26]= "26 view instructions" $charcnt = 0 $reportname_show = "" while $reportname[$charcnt] <> " " $reportname_show = $reportname_show & @CR & $reportname[$charcnt] $charcnt = $charcnt + 1 WEnd $selection = InputBox("Baan Reports Selection",$reportname_show & @CR & @CR &"For instructions on what the program does key in 26" & @CR & "Please Enter selection as Numbers, with 1 space in-between" ,""," M",350,550,650,450) If @error Then Exit sleep(10) $charcnt = 1 $selected = "" $selectedflag = StringSplit(" ","") $reportname[0] = "" while $charcnt < 40 if int(Stringmid($selection, $charcnt,1)) >= 0 then if int(Stringmid($selection, $charcnt,2)) < 10 then $selected = $selected & @CR & $reportname[int(Stringmid($selection, $charcnt,1))] $selectedflag[$charcnt] = int(Stringmid($selection, $charcnt,1)) $charcnt = $charcnt + 2 Else $selected = $selected & @CR & $reportname[int(Stringmid($selection, $charcnt,2))] $selectedflag[$charcnt] = int(Stringmid($selection, $charcnt,2)) $charcnt = $charcnt + 3 EndIf EndIf WEnd $input = MsgBox(1, "", "Reports Selected -> START ALL RANGE:" & @CR & $selected & @CR & @CR &"Click Ok to proceed, Cancel to End") if $input = 2 Then Exit EndIf $baantmpdir = "C:\Users\" & @UserName & "\AppData\Local\Infor\BW\Baan IV\" $baandir = "C:\Program Files (x86)\Infor\BW\Baan IV\" $Baan = 'tipcs2401m020 : Print Projects Closing Report' $BaanNo = 'Print Projects Closing Report' $Baan2 = 'tipcs2521m010 : Display Customized Item Data' $BaanNo2 = 'Display Customized Item Data' $Baan3 ='tdilc1413m000 : Print Inventories by Item and Warehouse' $BaanNo3 = 'Print Inventories by Item and Warehouse' $Baan4 ='tdsls4408m000 : Print Sales Orders by Item' $BaanNo4 ='Print Sales Orders by Item' $Baan5 = 'tiitm0401m000 : Print Item Data' $BaanNo5 ='Print Item Data' $Baan6 = 'tdpur4408m000 : Print Purchase Orders by Item' $BaanNo6 = 'Print Purchase Orders by Item' $Baan7 = 'tipcs5431m000 : Print Planned PRP Warehouse Orders (Project to Project)' $BaanNo7 = 'Print Planned PRP Warehouse Orders' $Baan8 = 'tipcs5430m010 : Print Planned PRP Warehouse Orders (Wrh to Project)' $BaanNo8 = 'tipcs5430m010' $Nowtime = @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC $YY=StringFormat("%02i",@YEAR-2000) $MM=StringFormat("%02i",Int(@MON)) $DD=StringFormat("%02i",Int(@MDAY)) $Baan_exist = 0 If WinExists("Menu browser [User: ") then $Baan_exist = 1 EndIf $charcnt = 1 Global $flag = 0 while $charcnt < 40 If $selectedflag[$charcnt] = 26 Then MsgBox(1, "Instructions", _ "1) Enter the report number in the box with a space in between." & @LF & _ "2) Reports 1 to 20 are reports with All project range." & @LF & _ "3) If you key in 21 it will run all reports from 1 to 20." & @LF & _ "4) Reports 22 and 23 are reports where you select the project range." & @LF & _ "5) Number 24 runs a macro to compile reports 22 and 23 and saves it. " & @LF & _ "6) Before running 24,ensure the files to be compiled are there in the folder." & @LF & _ "7) Report 25 runs 22 to 24 together." & @LF & _ "8) Each report is saved in a default folder and the setting can be changed easily." & @LF & _ "9) 27 will delete all .xls files from autodownload/.xls folder." _ ) Exit if $input = 2 Then Exit EndIf EndIf Switch $selectedflag[$charcnt] case 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23 If Not $flag Then $sFileSelectFolder = FileSelectFolder("Select the save location", "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download") If @error Then ; Display the error message. MsgBox($MB_SYSTEMMODAL, "", "No location was selected.") Exit Else ; Display the selected folder. $input= MsgBox(1, "", "You chose the following location:" & @CRLF & $sFileSelectFolder) if $input = 2 Then Exit EndIf ; <<<<<<<<<<<<<<<<< Add this $Flag = 1 EndIf EndIf ; < ;1)SO if $selectedflag[$charcnt] = 1 Or $selectedflag[$charcnt] = 21 Then If WinExists("Menu browser [User: ") then WinActivate("Menu browser [User: ") EndIf If NOT(WinExists("Menu browser [User: ")) then Run($baandir & "bin\bw.exe", $baandir & "bin") WinWaitActive("Login for SU304001") WinActivate("Login for SU304001") SendKeepActive("Login for SU304001") Send('') EndIf WinWaitActive("Menu browser [User: ", "" ,60) If NOT(WinExists("Menu browser [User: ")) Then msgbox(1,"","No login yet. Program will Exit.") Exit EndIf $BaanDesc= 'mtgxxxpr410001' WinActivate("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}") Sleep(500) $BaanDesc = 'mtgxxxpr410002' SendKeepActive ("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}") SendKeepActive("") Sleep(500) $BaanDesc = 'mtgxxxpr410018' SendKeepActive ("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") ;need to add enter SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}") Sleep(500) SendKeepActive("") Sleep(1000) $BaanDesc='tdsls4408m000' WinActivate("Menu browser [User: ") SendKeepActive("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}") Sleep(500) WinActive('tdsls4408m000 : Print Sales Orders by Item') WinWaitActive("tdsls4408m000 : Print Sales Orders by Item") Send('{TAB 7}31122900') sleep(100) Send('{TAB 7}') Sleep(500) Send('{ENTER}{DOWN 2}') ;22 sleep(500) send('{ENTER}') WinWaitActive("ttstpsplopen : Select Device [000]") WinActivate("ttstpsplopen : Select Device [000]") SendKeepActive("ttstpsplopen : Select Device [000]") ClipPut("") While ClipGet() <> "EBAAN" sleep(100) Send("^e") sleep(100) Send("EBAAN") sleep(100) Send("^e") sleep(100) Send('^c') sleep(100) WEnd sleep(100) Send("{ENTER}") $fileoutput = false while $fileoutput = false WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") If WinExists ('File in Use') Then Send("{ENTER}") sleep(100) Send("{ENTER}") sleep(100) Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true endif EndIf EndIf If Not WinExists ('File in Use') Then WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true EndIf EndIf EndIf FileCopy($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt", "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\SO " & $YY & $MM & $DD & ".xls") WinActivate($Baan4) WinClose($Baan4) WinActivate($title1) WinClose($title1) Global $oExcel = _Excel_Open() If @error Then Exit MsgBox(0, "Error", "_Excel_Open returned @error = " & @error & ", @extended = " & @extended) Global $sWorkbook = $sFileSelectFolder &"\SO " & $YY & $MM & $DD Global $oWorkbook = _Excel_BookOpen($oExcel, "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\SO " & $yy & $mm & $dd & ".xls") If @error Then Exit MsgBox(0, "Error", "_Excel_BookOpen returned @error = " & @error & ", @extended = " & @extended) _Excel_BookSaveAs($oWorkbook, $sWorkbook & ".xlsx", $xlWorkbookDefault,True) If @error Then Exit MsgBox(0, "Error", "_Excel_BookSaveAs returned @error = " & @error & ", @extended = " & @extended) _Excel_BookClose($oWorkbook) If @error Then Exit MsgBox(0, "Error", "_Excel_BookClose returned @error = " & @error & ", @extended = " & @extended) _Excel_Close($oExcel) If @error Then Exit MsgBox(0, "Error", "_Excel_Close returned @error = " & @error & ", @extended = " & @extended) MsgBox ( 0, "status",$reportname[1] & " report complete" ,3 ) WEnd EndIf sleep(10) ;2)PRP Pro if $selectedflag[$charcnt] = 2 Or $selectedflag[$charcnt] = 21 Then If WinExists("Menu browser [User: ") then WinActivate("Menu browser [User: ") EndIf If NOT(WinExists("Menu browser [User: ")) then Run($baandir & "bin\bw.exe", $baandir & "bin") WinWaitActive("Login for SU304001") WinActivate("Login for SU304001") SendKeepActive("Login for SU304001") Send('') EndIf WinWaitActive("Menu browser [User: ", "" ,60) If NOT(WinExists("Menu browser [User: ")) Then msgbox(1,"","No login yet. Program will Exit.") Exit EndIf $BaanDesc= 'mtgxxxlo040001' WinActivate("Menu browser [User: ") Send("!i{DOWN}{ENTER}") Sleep(500) WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}") Sleep(500) $BaanDesc = 'mtgxxxlo040007' SendKeepActive ("Menu browser [User: ") Sleep(500) Send("!i{DOWN}{ENTER}") Sleep(500) WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}") SendKeepActive("") sleep(500) $BaanDesc = 'tccomlog01001' SendKeepActive ("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}") SendKeepActive("") Sleep(500) Send('{ENTER}') WinWaitActive("Queries Logistics employee - Zoom") Send ('{DOWN 5}{ENTER}') Sleep(500) WinWaitActive('ttadv3480m000') Send('{DOWN 3}') sleep(500) Send('confirmed') Sleep(500) Send('{DOWN}{RIGHT 12}') sleep(500) Send('1900'&'{DOWN}{RIGHT 12}' &'2900' & '{DOWN 5}{A}{DOWN 2}{Y}') Sleep(500) WinWaitActive("ttstpsplopen : Select Device [000]") WinActivate("ttstpsplopen : Select Device [000]") SendKeepActive("ttstpsplopen : Select Device [000]") ClipPut("") While ClipGet() <> "EBAAN" sleep(100) Send("^e") sleep(100) Send("EBAAN") sleep(100) Send("^e") sleep(100) Send('^c') WEnd Sleep(500) Send("{ENTER}") $fileoutput = false while $fileoutput = false WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") If WinExists ('File in Use') Then Send("{ENTER}") sleep(100) Send("{ENTER}") sleep(100) Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true endif EndIf EndIf If Not WinExists ('File in Use') Then WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true EndIf EndIf EndIf FileCopy($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt", "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\PRP_Production " & $YY & $MM & $DD & ".xls", 1) WinClose('tccompro03001 : Queries Project Monitoring (M&S)') WinActivate($title1) WinClose($title1) Global $oExcel = _Excel_Open() If @error Then Exit MsgBox(0, "Error", "_Excel_Open returned @error = " & @error & ", @extended = " & @extended) Global $sWorkbook = $sFileSelectFolder &"\PRP_Production " & $YY & $MM & $DD Global $oWorkbook = _Excel_BookOpen($oExcel, "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\PRP_Production " & $yy & $mm & $dd & ".xls") If @error Then Exit MsgBox(0, "Error", "_Excel_BookOpen returned @error = " & @error & ", @extended = " & @extended) _Excel_BookSaveAs($oWorkbook, $sWorkbook & ".xlsx", $xlWorkbookDefault,True) If @error Then Exit MsgBox(0, "Error", "_Excel_BookSaveAs returned @error = " & @error & ", @extended = " & @extended) _Excel_BookClose($oWorkbook) If @error Then Exit MsgBox(0, "Error", "_Excel_BookClose returned @error = " & @error & ", @extended = " & @extended) _Excel_Close($oExcel) If @error Then Exit MsgBox(0, "Error", "_Excel_Close returned @error = " & @error & ", @extended = " & @extended) MsgBox ( 0, "status",$reportname[2] & " report complete" ,3 ) WEnd EndIf Sleep(10) ;3)PRP Pur if $selectedflag[$charcnt] = 3 Then If WinExists("Menu browser [User: ") then WinActivate("Menu browser [User: ") EndIf If NOT(WinExists("Menu browser [User: ")) then Run($baandir & "bin\bw.exe", $baandir & "bin") WinWaitActive("Login for SU304001") WinActivate("Login for SU304001") SendKeepActive("Login for SU304001") Send('') EndIf WinWaitActive("Menu browser [User: ", "" ,60) If NOT(WinExists("Menu browser [User: ")) Then msgbox(1,"","No login yet. Program will Exit.") Exit EndIf $BaanDesc= 'mtgxxxlo040001' WinActivate("Menu browser [User: ") Send("!i{DOWN}{ENTER}") Sleep(500) WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}") Sleep(500) $BaanDesc = 'mtgxxxlo040007' SendKeepActive ("Menu browser [User: ") Sleep(500) Send("!i{DOWN}{ENTER}") Sleep(500) WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}") SendKeepActive("") sleep(500) $BaanDesc = 'tccomlog01001' SendKeepActive ("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}") Sleep(500) Send('{ENTER}') WinWaitActive('Queries Logistics employee') Send('{DOWN 4}{ENTER}') WinWaitActive("ttadv3480m000") Sleep(500) Send('{DOWN 3}') sleep(500) Send('confirmed') sleep(500) Send('{DOWN}{RIGHT 12}') Send('1900'&'{DOWN}{RIGHT 12}' &'2900' & '{DOWN 5}{A}{DOWN 4}{Y}') Sleep(1000) WinWaitActive("ttstpsplopen : Select Device [000]") WinActivate("ttstpsplopen : Select Device [000]") SendKeepActive("ttstpsplopen : Select Device [000]") ClipPut("") While ClipGet() <> "EBAAN" sleep(100) Send("^e") sleep(100) Send("EBAAN") sleep(100) Send("^e") sleep(100) Send('^c') WEnd Sleep(500) Send("{ENTER}") WinClose('tccompro03001 : Queries Project Monitoring (M&S)') Sleep(1000) $fileoutput = false while $fileoutput = false WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") If WinExists ('File in Use') Then Send("{ENTER}") sleep(100) Send("{ENTER}") sleep(100) Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true endif EndIf EndIf If Not WinExists ('File in Use') Then WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true EndIf EndIf EndIf FileCopy($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt", "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\PRP_purchase " & $YY & $MM & $DD & ".xls" , 1) WinClose('tccompro03001 : Queries Project Monitoring (M&S) [108]') WinActivate($title1) WinClose($title1) Global $oExcel = _Excel_Open() If @error Then Exit MsgBox(0, "Error", "_Excel_Open returned @error = " & @error & ", @extended = " & @extended) Global $sWorkbook = $sFileSelectFolder &"\PRP_purchase " & $YY & $MM & $DD Global $oWorkbook = _Excel_BookOpen($oExcel, "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\PRP_purchase " & $yy & $mm & $dd & ".xls") If @error Then Exit MsgBox(0, "Error", "_Excel_BookOpen returned @error = " & @error & ", @extended = " & @extended) _Excel_BookSaveAs($oWorkbook, $sWorkbook & ".xlsx", $xlWorkbookDefault,True) If @error Then Exit MsgBox(0, "Error", "_Excel_BookSaveAs returned @error = " & @error & ", @extended = " & @extended) _Excel_BookClose($oWorkbook) If @error Then Exit MsgBox(0, "Error", "_Excel_BookClose returned @error = " & @error & ", @extended = " & @extended) _Excel_Close($oExcel) If @error Then Exit MsgBox(0, "Error", "_Excel_Close returned @error = " & @error & ", @extended = " & @extended) MsgBox ( 0, "status",$reportname[3] & " report complete" ,3 ) WEnd EndIf sleep(10) ;4)Prod CLAIM if $selectedflag[$charcnt] = 4 Or $selectedflag[$charcnt] = 21 Then If WinExists("Menu browser [User: ") then WinActivate("Menu browser [User: ") EndIf If NOT(WinExists("Menu browser [User: ")) then Run($baandir & "bin\bw.exe", $baandir & "bin") WinWaitActive("Login for SU304001") WinActivate("Login for SU304001") SendKeepActive("Login for SU304001") Send('') EndIf WinWaitActive("Menu browser [User: ", "" ,60) If NOT(WinExists("Menu browser [User: ")) Then msgbox(1,"","No login yet. Program will Exit.") Exit EndIf $BaanDesc= 'mtgxxxpr410001' WinActivate("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}{ENTER}") Sleep(500) $BaanDesc = 'mtgxxxpr410002' SendKeepActive ("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}{ENTER}") SendKeepActive("") Sleep(500) $BaanDesc = 'mtgxxxpr410014' SendKeepActive ("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") ;need to add enter SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}") Sleep(500) SendKeepActive("") Sleep(1000) $BaanDesc = 'tisfc1410m000' SendKeepActive ("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}") SendKeepActive("") Sleep(500) Send('{ENTER}') WinWaitActive("tisfc1410m000 : Print Production Order Planning by Priority") Send('^e{0}{TAB}999999{TAB}{SPACE}{TAB}ZZZZZZ') Sleep(500) Send('{TAB 4}31122900') sleep(500) Send('{TAB 2}31122900{TAB 9}31122900{TAB 4}31122900{TAB 4}E') sleep(500) Send('{TAB}{ENTER}') Sleep(500) WinWaitActive("ttstpsplopen : Select Device [000]") WinActivate("ttstpsplopen : Select Device [000]") SendKeepActive("ttstpsplopen : Select Device [000]") ClipPut("") ClipPut("") While ClipGet() <> "EBAAN" sleep(100) Send("^e") sleep(100) Send("EBAAN") sleep(100) Send("^e") sleep(100) Send('^c') WEnd sleep(1000) Send("{ENTER}") $fileoutput = false while $fileoutput = false WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") If WinExists ('File in Use') Then Send("{ENTER}") sleep(100) Send("{ENTER}") sleep(100) Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true endif EndIf EndIf If Not WinExists ('File in Use') Then WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true EndIf EndIf EndIf FileCopy($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt", "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\Prod_Claim " & $YY & $MM & $DD & ".xls", 1) WinActivate('tisfc1410m000') WinClose('tisfc1410m000') WinActivate($title1) WinClose($title1) Global $oExcel = _Excel_Open() If @error Then Exit MsgBox(0, "Error", "_Excel_Open returned @error = " & @error & ", @extended = " & @extended) Global $sWorkbook = $sFileSelectFolder &"\Prod_Claim " & $YY & $MM & $DD Global $oWorkbook = _Excel_BookOpen($oExcel, "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\Prod_Claim " & $yy & $mm & $dd & ".xls") If @error Then Exit MsgBox(0, "Error", "_Excel_BookOpen returned @error = " & @error & ", @extended = " & @extended) _Excel_BookSaveAs($oWorkbook, $sWorkbook & ".xlsx", $xlWorkbookDefault,True) If @error Then Exit MsgBox(0, "Error", "_Excel_BookSaveAs returned @error = " & @error & ", @extended = " & @extended) _Excel_BookClose($oWorkbook) If @error Then Exit MsgBox(0, "Error", "_Excel_BookClose returned @error = " & @error & ", @extended = " & @extended) _Excel_Close($oExcel) If @error Then Exit MsgBox(0, "Error", "_Excel_Close returned @error = " & @error & ", @extended = " & @extended) MsgBox ( 0, "status",$reportname[4] & " report complete" ,3 ) WEnd EndIf Sleep(10) ;5)purchase claim(finished) if $selectedflag[$charcnt] = 5 Then If WinExists("Menu browser [User: ") then WinActivate("Menu browser [User: ") EndIf If NOT(WinExists("Menu browser [User: ")) then Run($baandir & "bin\bw.exe", $baandir & "bin") WinWaitActive("Login for SU304001") WinActivate("Login for SU304001") SendKeepActive("Login for SU304001") Send('') EndIf WinWaitActive("Menu browser [User: ", "" ,120) If NOT(WinExists("Menu browser [User: ")) Then msgbox(1,"","No login yet. Program will Exit.") Exit EndIf $BaanDesc= 'mtgxxxpr410001' WinActivate("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}{ENTER}") Sleep(500) $BaanDesc = 'mtgxxxpr410002' SendKeepActive ("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}{ENTER}") SendKeepActive("") Sleep(500) $BaanDesc = 'mtgxxxpr410011' SendKeepActive ("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}") Sleep(500) SendKeepActive("") Sleep(1000) WinActivate("Menu browser [User: ") SendKeepActive("Menu browser [User: ") Send("!i{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanNo6 & "{ENTER}{ENTER}") Sleep(1000) WinWaitActive('tdpur4408m000') Send('{TAB 6}01011900{TAB}31122900{TAB 7}{ENTER}') Sleep(1000) Send('{DOWN}{ENTER}') Sleep(1000) WinWaitActive("ttstpsplopen : Select Device [000]") WinActivate("ttstpsplopen : Select Device [000]") SendKeepActive("ttstpsplopen : Select Device [000]") ClipPut("") While ClipGet() <> "EBAAN" sleep(100) Send("^e") sleep(100) Send("EBAAN") sleep(100) Send("^e") sleep(100) Send('^c') WEnd Sleep(500) Send("{ENTER}") Sleep(1000) $fileoutput = false while $fileoutput = false WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") If WinExists ('File in Use') Then Send("{ENTER}") sleep(100) Send("{ENTER}") sleep(100) Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true endif EndIf EndIf If Not WinExists ('File in Use') Then WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true EndIf EndIf EndIf FileCopy($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt", "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\Purchase_claim " & $YY & $MM & $DD & ".xls", 1) WinActivate($Baan6) WinClose($Baan6) WinActivate($title1) WinClose($title1) Global $oExcel = _Excel_Open() If @error Then Exit MsgBox(0, "Error", "_Excel_Open returned @error = " & @error & ", @extended = " & @extended) Global $sWorkbook = $sFileSelectFolder &"\Purchase_claim " & $YY & $MM & $DD Global $oWorkbook = _Excel_BookOpen($oExcel, "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\Purchase_claim " & $yy & $mm & $dd & ".xls") If @error Then Exit MsgBox(0, "Error", "_Excel_BookOpen returned @error = " & @error & ", @extended = " & @extended) _Excel_BookSaveAs($oWorkbook, $sWorkbook & ".xlsx", $xlWorkbookDefault,True) If @error Then Exit MsgBox(0, "Error", "_Excel_BookSaveAs returned @error = " & @error & ", @extended = " & @extended) _Excel_BookClose($oWorkbook) If @error Then Exit MsgBox(0, "Error", "_Excel_BookClose returned @error = " & @error & ", @extended = " & @extended) _Excel_Close($oExcel) If @error Then Exit MsgBox(0, "Error", "_Excel_Close returned @error = " & @error & ", @extended = " & @extended) MsgBox ( 0, "status",$reportname[5] & " report complete" ,3 ) WEnd EndIf sleep(10) ;6)BUY 2 WHAREHOUSE if $selectedflag[$charcnt] = 6 Or $selectedflag[$charcnt] = 21 Then If WinExists("Menu browser [User: ") then WinActivate("Menu browser [User: ") EndIf If NOT(WinExists("Menu browser [User: ")) then Run($baandir & "bin\bw.exe", $baandir & "bin") WinWaitActive("Login for SU304001") WinActivate("Login for SU304001") SendKeepActive("Login for SU304001") Send('') EndIf WinWaitActive("Menu browser [User: ", "" ,60) If NOT(WinExists("Menu browser [User: ")) Then msgbox(1,"","No login yet. Program will Exit.") Exit EndIf $BaanDesc= 'mtgxxxpr410001' WinActivate("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Sleep(500) Send($BaanDesc & "{ENTER}{ENTER}") Sleep(500) $BaanDesc = 'mtgxxxpr410002' SendKeepActive ("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Sleep(500) Send($BaanDesc & "{ENTER}{ENTER}") SendKeepActive("") Sleep(500) $BaanDesc = 'mtgxxxpr410009' SendKeepActive ("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}") Sleep(500) SendKeepActive("") Sleep(100) $Baan10= 'tdinv1450m000 : Print Planned Inventory Transactions by Item' $BaanNo10 ='Print Planned Inventory Transactions by Item' WinActivate("Menu browser [User: ") SendKeepActive("Menu browser [User: ") Send("!i{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanNo10 & "{ENTER}{ENTER}") Sleep(500) Send('{DOWN}{DOWN}{DOWN}{ENTER}') sleep(500) Send('{DOWN 5}{ENTER}') WinWaitActive("ttstpsplopen : Select Device [000]") WinActivate("ttstpsplopen : Select Device [000]") SendKeepActive("ttstpsplopen : Select Device [000]") ClipPut("") ClipPut("") While ClipGet() <> "EBAAN" sleep(100) Send("^e") sleep(100) Send("EBAAN") sleep(100) Send("^e") sleep(100) Send('^c') WEnd sleep(1000) Send("{ENTER}") $fileoutput = false while $fileoutput = false WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") If WinExists ('File in Use') Then Send("{ENTER}") sleep(100) Send("{ENTER}") sleep(100) Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true endif EndIf EndIf If Not WinExists ('File in Use') Then WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true EndIf EndIf EndIf FileCopy($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt", "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\BUY_2_WHAREHOUSE " & $YY & $MM & $DD & ".xls", 1) WinActivate($Baan10) WinClose($Baan10) WinActivate($title1) WinClose($title1) Global $oExcel = _Excel_Open() If @error Then Exit MsgBox(0, "Error", "_Excel_Open returned @error = " & @error & ", @extended = " & @extended) Global $sWorkbook = $sFileSelectFolder &"\BUY_2_WHAREHOUSE " & $YY & $MM & $DD Global $oWorkbook = _Excel_BookOpen($oExcel, "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\BUY_2_WHAREHOUSE " & $yy & $mm & $dd & ".xls") If @error Then Exit MsgBox(0, "Error", "_Excel_BookOpen returned @error = " & @error & ", @extended = " & @extended) _Excel_BookSaveAs($oWorkbook, $sWorkbook & ".xlsx", $xlWorkbookDefault,True) If @error Then Exit MsgBox(0, "Error", "_Excel_BookSaveAs returned @error = " & @error & ", @extended = " & @extended) _Excel_BookClose($oWorkbook) If @error Then Exit MsgBox(0, "Error", "_Excel_BookClose returned @error = " & @error & ", @extended = " & @extended) _Excel_Close($oExcel) If @error Then Exit MsgBox(0, "Error", "_Excel_Close returned @error = " & @error & ", @extended = " & @extended) MsgBox ( 0, "status",$reportname[6] & " report complete" ,3 ) WEnd EndIf Sleep(10) ;7)PRP whs(W2P and P2W) if $selectedflag[$charcnt] = 7 Or $selectedflag[$charcnt] = 21 Then If WinExists("Menu browser [User: ") then WinActivate("Menu browser [User: ") EndIf If NOT(WinExists("Menu browser [User: ")) then Run($baandir & "bin\bw.exe", $baandir & "bin") WinWaitActive("Login for SU304001") WinActivate("Login for SU304001") SendKeepActive("Login for SU304001") Send('') EndIf WinWaitActive("Menu browser [User: ", "" ,60) If NOT(WinExists("Menu browser [User: ")) Then msgbox(1,"","No login yet. Program will Exit.") Exit EndIf $BaanDesc= 'mtgxxxlo040001' WinActivate("Menu browser [User: ") Send("!i{DOWN}{ENTER}") Sleep(500) WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}") Sleep(500) $BaanDesc = 'mtgxxxlo040006' SendKeepActive ('Menu browser [User: SysPlan2 ] [108]') Sleep(500) Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}") Sleep(500) SendKeepActive("") Sleep(500) WinActivate("Menu browser [User: ") SendKeepActive("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanNo8 & "{ENTER}{ENTER}") Sleep(500) WinWaitActive($Baan8) Send(' '&'{TAB 2}{TAB}999999') Sleep(500) Send('{TAB}{W}{TAB}{P}{TAB 9}') Sleep(500) Send('{TAB}31122900{TAB 2}{C}{TAB}{Y}{TAB}{Y}{TAB}{ENTER}') Sleep(500) Send('{DOWN 5}{ENTER}') WinWaitActive("ttstpsplopen : Select Device [000]") WinActivate("ttstpsplopen : Select Device [000]") SendKeepActive("ttstpsplopen : Select Device [000]") ClipPut("") ClipPut("") While ClipGet() <> "EBAAN" sleep(100) Send("^e") sleep(100) Send("EBAAN") sleep(100) Send("^e") sleep(100) Send('^c') WEnd sleep(500) Send("{ENTER}") $fileoutput = false while $fileoutput = false WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") If WinExists ('File in Use') Then Send("{ENTER}") sleep(100) Send("{ENTER}") sleep(100) Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true endif EndIf EndIf If Not WinExists ('File in Use') Then WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true EndIf EndIf EndIf FileCopy($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt", "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\W2P&P2W " & $YY & $MM & $DD & ".xls", 1) WinClose('ttstps0014 : Print Planned PRP Warehouse Orders (Wrh to Project)') WinClose('Reports') WinActivate($Baan8) WinClose($Baan8) WinActivate($title1) WinClose($title1) Global $oExcel = _Excel_Open() If @error Then Exit MsgBox(0, "Error", "_Excel_Open returned @error = " & @error & ", @extended = " & @extended) Global $sWorkbook = $sFileSelectFolder &"\W2P&P2W " & $YY & $MM & $DD Global $oWorkbook = _Excel_BookOpen($oExcel, "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\W2P&P2W " & $yy & $mm & $dd & ".xls") If @error Then Exit MsgBox(0, "Error", "_Excel_BookOpen returned @error = " & @error & ", @extended = " & @extended) _Excel_BookSaveAs($oWorkbook, $sWorkbook & ".xlsx", $xlWorkbookDefault,True) If @error Then Exit MsgBox(0, "Error", "_Excel_BookSaveAs returned @error = " & @error & ", @extended = " & @extended) _Excel_BookClose($oWorkbook) If @error Then Exit MsgBox(0, "Error", "_Excel_BookClose returned @error = " & @error & ", @extended = " & @extended) _Excel_Close($oExcel) If @error Then Exit MsgBox(0, "Error", "_Excel_Close returned @error = " & @error & ", @extended = " & @extended) MsgBox ( 0, "status",$reportname[7] & " report complete" ,3 ) WEnd EndIf Sleep(10) ;8)proj to proj if $selectedflag[$charcnt] = 8 Or $selectedflag[$charcnt] = 21 Then If WinExists("Menu browser [User: ") then WinActivate("Menu browser [User: ") EndIf If NOT(WinExists("Menu browser [User: ")) then Run($baandir & "bin\bw.exe", $baandir & "bin") WinWaitActive("Login for SU304001") WinActivate("Login for SU304001") SendKeepActive("Login for SU304001") Send('') EndIf WinWaitActive("Menu browser [User: ", "" ,60) If NOT(WinExists("Menu browser [User: ")) Then msgbox(1,"","No login yet. Program will Exit.") Exit EndIf $BaanDesc= 'mtgxxxlo040001' WinActivate("Menu browser [User: ") Send("!i{DOWN}{ENTER}") Sleep(1000) WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}") Sleep(1000) $BaanDesc = 'mtgxxxlo040005' SendKeepActive ('Menu browser [User: SysPlan2 ] [108]') Sleep(500) Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}") Sleep(500) SendKeepActive("") Sleep(1000) $BaanDesc='tipcs5431m000' WinActivate("Menu browser [User: ") SendKeepActive("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send( $BaanDesc & "{ENTER}{ENTER}") sleep(1000) WinWaitActive('tipcs5431m000 : Print Planned PRP Warehouse Orders (Project to Project) [108]') Send(' '&'{TAB 4}1{TAB}999999{TAB 2}PCS Project{TAB 9}') Sleep(500) Send('{TAB}31122900{TAB 2}') sleep(1000) Send('{C}{O}{TAB}{N}{TAB}{Y}{TAB}{ENTER}') Sleep(1000) Send('{DOWN 3}{ENTER}') WinWaitActive("ttstpsplopen : Select Device [000]") WinActivate("ttstpsplopen : Select Device [000]") SendKeepActive("ttstpsplopen : Select Device [000]") ClipPut("") ClipPut("") While ClipGet() <> "EBAAN" sleep(100) Send("^e") sleep(100) Send("EBAAN") sleep(100) Send("^e") sleep(100) Send('^c') WEnd sleep(1000) Send("{ENTER}") $fileoutput = false while $fileoutput = false WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") If WinExists ('File in Use') Then Send("{ENTER}") sleep(100) Send("{ENTER}") sleep(100) Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true endif EndIf EndIf If Not WinExists ('File in Use') Then WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true EndIf EndIf EndIf FileCopy($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt", "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\P2P(with cost) " & $YY & $MM & $DD & ".xls", 1) WinActivate($Baan7) WinClose($Baan7) WinActivate($title1) WinClose($title1) Global $oExcel = _Excel_Open() If @error Then Exit MsgBox(0, "Error", "_Excel_Open returned @error = " & @error & ", @extended = " & @extended) Global $sWorkbook = $sFileSelectFolder &"\P2P(with cost) " & $YY & $MM & $DD Global $oWorkbook = _Excel_BookOpen($oExcel, "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\P2P(with cost) " & $yy & $mm & $dd & ".xls") If @error Then Exit MsgBox(0, "Error", "_Excel_BookOpen returned @error = " & @error & ", @extended = " & @extended) _Excel_BookSaveAs($oWorkbook, $sWorkbook & ".xlsx", $xlWorkbookDefault,True) If @error Then Exit MsgBox(0, "Error", "_Excel_BookSaveAs returned @error = " & @error & ", @extended = " & @extended) _Excel_BookClose($oWorkbook) If @error Then Exit MsgBox(0, "Error", "_Excel_BookClose returned @error = " & @error & ", @extended = " & @extended) _Excel_Close($oExcel) If @error Then Exit MsgBox(0, "Error", "_Excel_Close returned @error = " & @error & ", @extended = " & @extended) MsgBox ( 0, "status",$reportname[8] & " report complete" ,3 ) WEnd EndIf Sleep(10) ;9)triggerlist program below if $selectedflag[$charcnt] = 9 Or $selectedflag[$charcnt] = 21 Then If WinExists("Menu browser [User: ") then WinActivate("Menu browser [User: ") EndIf If NOT(WinExists("Menu browser [User: ")) then Run($baandir & "bin\bw.exe", $baandir & "bin") WinWaitActive("Login for SU304001") WinActivate("Login for SU304001") SendKeepActive("Login for SU304001") Send('') EndIf WinWaitActive("Menu browser [User: ", "" ,60) If NOT(WinExists("Menu browser [User: ")) Then msgbox(1,"","No login yet. Program will Exit.") Exit EndIf $BaanDesc= 'mtgxxxpr410001' WinActivate("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}") Sleep(500) $BaanDesc = 'mtgxxxpr410003' SendKeepActive ("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}") SendKeepActive("") Sleep(500) Send('{ENTER}') Sleep(500) $BaanDesc = 'tccompro03001' SendKeepActive ("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}") SendKeepActive("") Sleep(500) Send('{ENTER}') WinWaitActive('Queries Project Monitoring') Send('{DOWN 23}') Sleep(1000) Send('{ENTER}') sleep(500) Send(' ') Sleep(500) Send('{DOWN 2}{Y}') Sleep(1000) WinWaitActive("ttstpsplopen : Select Device [000]") WinActivate("ttstpsplopen : Select Device [000]") SendKeepActive("ttstpsplopen : Select Device [000]") ClipPut("") While ClipGet() <> "EBAAN" sleep(100) Send("^e") sleep(100) Send("EBAAN") sleep(100) Send("^e") sleep(100) Send('^c') WEnd sleep(1000) Send("{ENTER}") $fileoutput = false while $fileoutput = false WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") If WinExists ('File in Use') Then Send("{ENTER}") sleep(100) Send("{ENTER}") sleep(100) Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true endif EndIf EndIf If Not WinExists ('File in Use') Then WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true EndIf EndIf EndIf FileCopy($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt", "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\Triggerlist " & $YY & $MM & $DD & ".xls", 1) WinClose('tccompro03001 : Queries Project Monitoring (M&S) [108]') WinActivate($title1) WinClose($title1) Global $oExcel = _Excel_Open() If @error Then Exit MsgBox(0, "Error", "_Excel_Open returned @error = " & @error & ", @extended = " & @extended) Global $sWorkbook = $sFileSelectFolder &"\Triggerlist " & $YY & $MM & $DD Global $oWorkbook = _Excel_BookOpen($oExcel, "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\Triggerlist " & $yy & $mm & $dd & ".xls") If @error Then Exit MsgBox(0, "Error", "_Excel_BookOpen returned @error = " & @error & ", @extended = " & @extended) _Excel_BookSaveAs($oWorkbook, $sWorkbook & ".xlsx", $xlWorkbookDefault,True) If @error Then Exit MsgBox(0, "Error", "_Excel_BookSaveAs returned @error = " & @error & ", @extended = " & @extended) _Excel_BookClose($oWorkbook) If @error Then Exit MsgBox(0, "Error", "_Excel_BookClose returned @error = " & @error & ", @extended = " & @extended) _Excel_Close($oExcel) If @error Then Exit MsgBox(0, "Error", "_Excel_Close returned @error = " & @error & ", @extended = " & @extended) MsgBox ( 0, "status",$reportname[9] & " report complete" ,3 ) WEnd EndIf Sleep(10) ;10)sub con claim if $selectedflag[$charcnt] = 10 Or $selectedflag[$charcnt] = 21 Then If WinExists("Menu browser [User: ") then WinActivate("Menu browser [User: ") EndIf If NOT(WinExists("Menu browser [User: ")) then Run($baandir & "bin\bw.exe", $baandir & "bin") WinWaitActive("Login for SU304001") WinActivate("Login for SU304001") SendKeepActive("Login for SU304001") Send('') EndIf WinWaitActive("Menu browser [User: ", "" ,60) If NOT(WinExists("Menu browser [User: ")) Then msgbox(1,"","No login yet. Program will Exit.") Exit EndIf $BaanDesc= 'mtgxxxsf020001' WinActivate("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Sleep(500) Send($BaanDesc & "{ENTER}{ENTER}") Sleep(500) $BaanDesc = 'mtgxxxsf020010' SendKeepActive ("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Sleep(500) Send($BaanDesc & "{ENTER}{ENTER}") SendKeepActive("") Sleep(500) $BaanDesc= 'tccomsfc02001' SendKeepActive ("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Sleep(500) Send($BaanDesc & "{ENTER}{ENTER}") WinWaitActive('Queries shopfloor planning employee') Send('{DOWN 6}{ENTER}') Sleep(500) WinActive('ttadv3480m000') WinWaitActive('ttadv3480m000') Sleep(500) Send('{RIGHT 12}') sleep(500) Send('1900'&'{DOWN}{RIGHT 12}' & '2900' & '{DOWN 5}{DOWN 2}{Y}') Sleep(1000) WinWaitActive("ttstpsplopen : Select Device [000]") WinActivate("ttstpsplopen : Select Device [000]") SendKeepActive("ttstpsplopen : Select Device [000]") ClipPut("") ClipPut("") While ClipGet() <> "EBAAN" sleep(100) Send("^e") sleep(100) Send("EBAAN") sleep(100) Send("^e") sleep(100) Send('^c') WEnd sleep(1000) Send("{ENTER}") $fileoutput = false while $fileoutput = false WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") If WinExists ('File in Use') Then Send("{ENTER}") sleep(100) Send("{ENTER}") sleep(100) Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true endif EndIf EndIf If Not WinExists ('File in Use') Then WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true EndIf EndIf EndIf FileCopy($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt", "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\SUB_CON_CLAIM " & $YY & $MM & $DD & ".xls", 1) WinActivate('tccomsfc02001') WinClose('tccomsfc02001') WinActivate($title1) WinClose($title1) Global $oExcel = _Excel_Open() If @error Then Exit MsgBox(0, "Error", "_Excel_Open returned @error = " & @error & ", @extended = " & @extended) Global $sWorkbook = $sFileSelectFolder &"\SUB_CON_CLAIM " & $YY & $MM & $DD Global $oWorkbook = _Excel_BookOpen($oExcel, "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\SUB_CON_CLAIM " & $yy & $mm & $dd & ".xls") If @error Then Exit MsgBox(0, "Error", "_Excel_BookOpen returned @error = " & @error & ", @extended = " & @extended) _Excel_BookSaveAs($oWorkbook, $sWorkbook & ".xlsx", $xlWorkbookDefault,True) If @error Then Exit MsgBox(0, "Error", "_Excel_BookSaveAs returned @error = " & @error & ", @extended = " & @extended) _Excel_BookClose($oWorkbook) If @error Then Exit MsgBox(0, "Error", "_Excel_BookClose returned @error = " & @error & ", @extended = " & @extended) _Excel_Close($oExcel) If @error Then Exit MsgBox(0, "Error", "_Excel_Close returned @error = " & @error & ", @extended = " & @extended) MsgBox ( 0, "status",$reportname[10] & " report complete" ,3 ) WEnd EndIf Sleep(10) ;11)INV Plan pur order if $selectedflag[$charcnt] = 11 Or $selectedflag[$charcnt] = 21 then If WinExists("Menu browser [User: ") then WinActivate("Menu browser [User: ") EndIf If NOT(WinExists("Menu browser [User: ")) then Run($baandir & "bin\bw.exe", $baandir & "bin") WinWaitActive("Login for SU304001") WinActivate("Login for SU304001") SendKeepActive("Login for SU304001") Send('') EndIf WinWaitActive("Menu browser [User: ", "" ,60) If NOT(WinExists("Menu browser [User: ")) Then msgbox(1,"","No login yet. Program will Exit.") Exit EndIf $BaanDesc= 'mtgxxxpu010001' WinActivate("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Sleep(500) Send($BaanDesc & "{ENTER}{ENTER}") Sleep(500) $BaanDesc = 'mtgxxxpu010004' SendKeepActive ("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Sleep(500) Send($BaanDesc & "{ENTER}{ENTER}") SendKeepActive("") Sleep(500) $BaanDesc= 'tdinv3420m000' SendKeepActive ("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Sleep(500) Send($BaanDesc & "{ENTER}{ENTER}") sleep(1000) WinWaitActive('tdinv3420m000') Send('{ENTER}') Sleep(500) Send('{DOWN 12}{ENTER}') Sleep(500) WinWaitActive("ttstpsplopen : Select Device [000]") WinActivate("ttstpsplopen : Select Device [000]") SendKeepActive("ttstpsplopen : Select Device [000]") ClipPut("") ClipPut("") While ClipGet() <> "EBAAN" sleep(100) Send("^e") sleep(100) Send("EBAAN") sleep(100) Send("^e") sleep(100) Send('^c') WEnd sleep(1000) Send("{ENTER}") $fileoutput = false while $fileoutput = false WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") If WinExists ('File in Use') Then Send("{ENTER}") sleep(100) Send("{ENTER}") sleep(100) Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true endif EndIf EndIf If Not WinExists ('File in Use') Then WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true EndIf EndIf EndIf FileCopy($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt", "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\INV_PLAN_PUR_ORDER " & $YY & $MM & $DD & ".xls", 1) WinActivate('tdinv3420m000') WinClose('tdinv3420m000') WinActivate($title1) WinClose($title1) Global $oExcel = _Excel_Open() If @error Then Exit MsgBox(0, "Error", "_Excel_Open returned @error = " & @error & ", @extended = " & @extended) Global $sWorkbook = $sFileSelectFolder &"\INV_PLAN_PUR_ORDER " & $YY & $MM & $DD Global $oWorkbook = _Excel_BookOpen($oExcel, "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\INV_PLAN_PUR_ORDER " & $yy & $mm & $dd & ".xls") If @error Then Exit MsgBox(0, "Error", "_Excel_BookOpen returned @error = " & @error & ", @extended = " & @extended) _Excel_BookSaveAs($oWorkbook, $sWorkbook & ".xlsx", $xlWorkbookDefault,True) If @error Then Exit MsgBox(0, "Error", "_Excel_BookSaveAs returned @error = " & @error & ", @extended = " & @extended) _Excel_BookClose($oWorkbook) If @error Then Exit MsgBox(0, "Error", "_Excel_BookClose returned @error = " & @error & ", @extended = " & @extended) _Excel_Close($oExcel) If @error Then Exit MsgBox(0, "Error", "_Excel_Close returned @error = " & @error & ", @extended = " & @extended) MsgBox ( 0, "status",$reportname[11] & " report complete" ,1000 ) WEnd EndIf Sleep(10) ;12)INV Plan Pro Orders if $selectedflag[$charcnt] = 12 Or $selectedflag[$charcnt] = 21 Then If WinExists("Menu browser [User: ") then WinActivate("Menu browser [User: ") EndIf If NOT(WinExists("Menu browser [User: ")) then Run($baandir & "bin\bw.exe", $baandir & "bin") WinWaitActive("Login for SU304001") WinActivate("Login for SU304001") SendKeepActive("Login for SU304001") Send('') EndIf WinWaitActive("Menu browser [User: ", "" ,60) If NOT(WinExists("Menu browser [User: ")) Then msgbox(1,"","No login yet. Program will Exit.") Exit EndIf $BaanDesc= 'mtgxxxsf020001' WinActivate("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Sleep(500) Send($BaanDesc & "{ENTER}{ENTER}") Sleep(500) $BaanDesc = 'mtgxxxsf020005' SendKeepActive ("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Sleep(500) Send($BaanDesc & "{ENTER}{ENTER}") SendKeepActive("") Sleep(500) $BaanDesc= 'tdinv3410m000' SendKeepActive ("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Sleep(500) Send($BaanDesc & "{ENTER}{ENTER}") sleep(1000) WinWaitActive('tdinv3410m000') Send('{ENTER}') Sleep(500) Send('{ENTER}') Sleep(500) WinWaitActive("ttstpsplopen : Select Device [000]") WinActivate("ttstpsplopen : Select Device [000]") SendKeepActive("ttstpsplopen : Select Device [000]") ClipPut("") ClipPut("") While ClipGet() <> "EBAAN" sleep(100) Send("^e") sleep(100) Send("EBAAN") sleep(100) Send("^e") sleep(100) Send('^c') WEnd sleep(1000) Send("{ENTER}") $fileoutput = false while $fileoutput = false WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") If WinExists ('File in Use') Then Send("{ENTER}") sleep(100) Send("{ENTER}") sleep(100) Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true endif EndIf EndIf If Not WinExists ('File in Use') Then WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true EndIf EndIf EndIf FileCopy($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt", "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\INV_PLAN_Pro_Order " & $YY & $MM & $DD & ".xls", 1) WinActivate('tdinv3410m000') WinClose('tdinv3410m000') WinActivate($title1) WinClose($title1) Global $oExcel = _Excel_Open() If @error Then Exit MsgBox(0, "Error", "_Excel_Open returned @error = " & @error & ", @extended = " & @extended) Global $sWorkbook = $sFileSelectFolder &"\INV_PLAN_Pro_Order " & $YY & $MM & $DD Global $oWorkbook = _Excel_BookOpen($oExcel, "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\INV_PLAN_Pro_Order " & $yy & $mm & $dd & ".xls") If @error Then Exit MsgBox(0, "Error", "_Excel_BookOpen returned @error = " & @error & ", @extended = " & @extended) _Excel_BookSaveAs($oWorkbook, $sWorkbook & ".xlsx", $xlWorkbookDefault,True) If @error Then Exit MsgBox(0, "Error", "_Excel_BookSaveAs returned @error = " & @error & ", @extended = " & @extended) _Excel_BookClose($oWorkbook) If @error Then Exit MsgBox(0, "Error", "_Excel_BookClose returned @error = " & @error & ", @extended = " & @extended) _Excel_Close($oExcel) If @error Then Exit MsgBox(0, "Error", "_Excel_Close returned @error = " & @error & ", @extended = " & @extended) MsgBox ( 0, "status",$reportname[12] & " report complete" ,3 ) WEnd EndIf Sleep(10) ;13)itm data if $selectedflag[$charcnt] = 13 Or $selectedflag[$charcnt] = 21 Then If WinExists("Menu browser [User: ") then WinActivate("Menu browser [User: ") EndIf If NOT(WinExists("Menu browser [User: ")) then Run($baandir & "bin\bw.exe", $baandir & "bin") WinWaitActive("Login for SU304001") WinActivate("Login for SU304001") SendKeepActive("Login for SU304001") Send('') EndIf WinWaitActive("Menu browser [User: ", "" ,60) If NOT(WinExists("Menu browser [User: ")) Then msgbox(1,"","No login yet. Program will Exit.") Exit EndIf $BaanDesc= 'mtgxxxpr410001' WinActivate("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}{ENTER}") Sleep(500) $BaanDesc = 'mtgxxxpr410002' SendKeepActive ("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}{ENTER}") SendKeepActive("") Sleep(500) $BaanDesc = 'mtgxxxpr410005' SendKeepActive ("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") ;need to add enter SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}") Sleep(500) SendKeepActive("") Sleep(1000) WinActivate("Menu browser [User: ") SendKeepActive("Menu browser [User: ") Send("!i{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanNo5 & "{ENTER}{ENTER}") WinActive($Baan5) WinWaitActive($Baan5) Send('{TAB 16}{ENTER}') Sleep(1000) Send('{ENTER}') WinWaitActive("ttstpsplopen : Select Device [000]") WinActivate("ttstpsplopen : Select Device [000]") SendKeepActive("ttstpsplopen : Select Device [000]") ClipPut("") While ClipGet() <> "EBAAN" sleep(100) Send("^e") sleep(100) Send("EBAAN") sleep(100) Send("^e") sleep(100) Send('^c') WEnd Sleep(1000) Send("{ENTER}") $fileoutput = false while $fileoutput = false WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") If WinExists ('File in Use') Then Send("{ENTER}") sleep(100) Send("{ENTER}") sleep(100) Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true endif EndIf EndIf If Not WinExists ('File in Use') Then WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true EndIf EndIf EndIf FileCopy($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt", "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\ITM_DATA " & $YY & $MM & $DD & ".xls", 1) WinClose('ttstps0014 : Print Item Data') WinActivate($Baan5) WinClose($Baan5) WinActivate($title1) WinClose($title1) Global $oExcel = _Excel_Open() If @error Then Exit MsgBox(0, "Error", "_Excel_Open returned @error = " & @error & ", @extended = " & @extended) Global $sWorkbook = $sFileSelectFolder &"\ITM_DATA " & $YY & $MM & $DD Global $oWorkbook = _Excel_BookOpen($oExcel, "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\ITM_DATA " & $yy & $mm & $dd & ".xls") If @error Then Exit MsgBox(0, "Error", "_Excel_BookOpen returned @error = " & @error & ", @extended = " & @extended) _Excel_BookSaveAs($oWorkbook, $sWorkbook & ".xlsx", $xlWorkbookDefault,True) If @error Then Exit MsgBox(0, "Error", "_Excel_BookSaveAs returned @error = " & @error & ", @extended = " & @extended) _Excel_BookClose($oWorkbook) If @error Then Exit MsgBox(0, "Error", "_Excel_BookClose returned @error = " & @error & ", @extended = " & @extended) _Excel_Close($oExcel) If @error Then Exit MsgBox(0, "Error", "_Excel_Close returned @error = " & @error & ", @extended = " & @extended) MsgBox ( 0, "status",$reportname[13] & " report complete" ,3 ) WEnd EndIf Sleep(10) ;14)material issue analysis if $selectedflag[$charcnt] = 14 Or $selectedflag[$charcnt] = 21 Then If WinExists("Menu browser [User: ") then WinActivate("Menu browser [User: ") EndIf If NOT(WinExists("Menu browser [User: ")) then Run($baandir & "bin\bw.exe", $baandir & "bin") WinWaitActive("Login for SU304001") WinActivate("Login for SU304001") SendKeepActive("Login for SU304001") Send('') EndIf WinWaitActive("Menu browser [User: ", "" ,60) If NOT(WinExists("Menu browser [User: ")) Then msgbox(1,"","No login yet. Program will Exit.") Exit EndIf $BaanDesc= 'mtgxxxpr410001' WinActivate("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") sleep(500) Send($BaanDesc & "{ENTER}{ENTER}") Sleep(500) $BaanDesc = 'mtgxxxpr410003' SendKeepActive ("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}") SendKeepActive("") Sleep(500) Send('{ENTER}') Sleep(500) $BaanDesc = 'tccompro03001' SendKeepActive ("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}") SendKeepActive("") Sleep(500) Send('{ENTER}') WinActive('Queries Project Monitoring') WinWaitActive('Queries Project Monitoring') Send('{DOWN 18}') Sleep(1000) Send('{ENTER}') sleep(500) WinActive('ttadv3480m000') Send(' ') Sleep(500) Send('{DOWN 4}{Y}') Sleep(1000) WinActivate("ttstpsplopen : Select Device [000]") WinWaitActive("ttstpsplopen : Select Device [000]") SendKeepActive("ttstpsplopen : Select Device [000]") ClipPut("") While ClipGet() <> "EBAAN" sleep(100) Send("^e") sleep(100) Send("EBAAN") sleep(100) Send("^e") sleep(100) Send('^c') WEnd sleep(1000) Send("{ENTER}") $fileoutput = false while $fileoutput = false WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") If WinExists ('File in Use') Then Send("{ENTER}") sleep(100) Send("{ENTER}") sleep(100) Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true endif EndIf EndIf If Not WinExists ('File in Use') Then WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true EndIf EndIf EndIf FileCopy($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt", "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\material_issue_analysis " & $YY & $MM & $DD & ".xls", 1) WinClose('tccompro03001 : Queries Project Monitoring (M&S) [108]') WinActivate($title1) WinClose($title1) Global $oExcel = _Excel_Open() If @error Then Exit MsgBox(0, "Error", "_Excel_Open returned @error = " & @error & ", @extended = " & @extended) Global $sWorkbook = $sFileSelectFolder &"\material_issue_analysis " & $YY & $MM & $DD Global $oWorkbook = _Excel_BookOpen($oExcel, "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\material_issue_analysis " & $yy & $mm & $dd & ".xls") If @error Then Exit MsgBox(0, "Error", "_Excel_BookOpen returned @error = " & @error & ", @extended = " & @extended) _Excel_BookSaveAs($oWorkbook, $sWorkbook & ".xlsx", $xlWorkbookDefault,True) If @error Then Exit MsgBox(0, "Error", "_Excel_BookSaveAs returned @error = " & @error & ", @extended = " & @extended) _Excel_BookClose($oWorkbook) If @error Then Exit MsgBox(0, "Error", "_Excel_BookClose returned @error = " & @error & ", @extended = " & @extended) _Excel_Close($oExcel) If @error Then Exit MsgBox(0, "Error", "_Excel_Close returned @error = " & @error & ", @extended = " & @extended) MsgBox ( 0, "status",$reportname[14] & " report complete" ,3 ) WEnd EndIf Sleep(10) ;15)IQA-LOC if $selectedflag[$charcnt] = 15 Or $selectedflag[$charcnt] = 21 Then If WinExists("Menu browser [User: ") then WinActivate("Menu browser [User: ") EndIf If NOT(WinExists("Menu browser [User: ")) then Run($baandir & "bin\bw.exe", $baandir & "bin") WinWaitActive("Login for SU304001") WinActivate("Login for SU304001") SendKeepActive("Login for SU304001") Send('') EndIf WinWaitActive("Menu browser [User: ", "" ,60) If NOT(WinExists("Menu browser [User: ")) Then msgbox(1,"","No login yet. Program will Exit.") Exit EndIf $BaanDesc= 'mtgxxxpr410001' WinActivate("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}{ENTER}") Sleep(500) $BaanDesc = 'mtgxxxpr410002' SendKeepActive ("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}{ENTER}") SendKeepActive("") Sleep(500) $BaanDesc = 'mtgxxxpr410022' SendKeepActive ("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") ;need to add enter SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}") Sleep(500) SendKeepActive("") Sleep(1000) $BaanDesc='tdilc1413m000' WinActivate("Menu browser [User: ") SendKeepActive("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}") Sleep(500) WinActive($Baan3) WinWaitActive($Baan3) Send('{TAB}') Sleep(500) Send('{TAB 7}IQA-LOC') Sleep(500) Send('{TAB 2}{ENTER}{DOWN 10}{ENTER}') Sleep(500) WinWaitActive("ttstpsplopen : Select Device [000]") WinActivate("ttstpsplopen : Select Device [000]") SendKeepActive("ttstpsplopen : Select Device [000]") ClipPut("") While ClipGet() <> "EBAAN" sleep(100) Send("^e") sleep(100) Send("EBAAN") sleep(100) Send("^e") sleep(100) Send('^c') WEnd Send("{ENTER}") sleep(2000) $fileoutput = false while $fileoutput = false WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") If WinExists ('File in Use') Then Send("{ENTER}") sleep(100) Send("{ENTER}") sleep(100) Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true endif EndIf EndIf If Not WinExists ('File in Use') Then WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true EndIf EndIf EndIf FileCopy($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt", "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\IQA_LOC " & $YY & $MM & $DD & ".xls", 1) WinActivate($Baan3) WinClose($Baan3) WinActivate($title1) WinClose($title1) Global $oExcel = _Excel_Open() If @error Then Exit MsgBox(0, "Error", "_Excel_Open returned @error = " & @error & ", @extended = " & @extended) Global $sWorkbook = $sFileSelectFolder &"\IQA_LOC " & $YY & $MM & $DD Global $oWorkbook = _Excel_BookOpen($oExcel, "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\IQA_LOC " & $yy & $mm & $dd & ".xls") If @error Then Exit MsgBox(0, "Error", "_Excel_BookOpen returned @error = " & @error & ", @extended = " & @extended) _Excel_BookSaveAs($oWorkbook, $sWorkbook & ".xlsx", $xlWorkbookDefault,True) If @error Then Exit MsgBox(0, "Error", "_Excel_BookSaveAs returned @error = " & @error & ", @extended = " & @extended) _Excel_BookClose($oWorkbook) If @error Then Exit MsgBox(0, "Error", "_Excel_BookClose returned @error = " & @error & ", @extended = " & @extended) _Excel_Close($oExcel) If @error Then Exit MsgBox(0, "Error", "_Excel_Close returned @error = " & @error & ", @extended = " & @extended) MsgBox ( 0, "status",$reportname[15] & " report complete" ,3 ) WEnd EndIf Sleep(10) ;16)ILC INV Data if $selectedflag[$charcnt] = 16 Or $selectedflag[$charcnt] = 21 Then If WinExists("Menu browser [User: ") then WinActivate("Menu browser [User: ") EndIf If NOT(WinExists("Menu browser [User: ")) then Run($baandir & "bin\bw.exe", $baandir & "bin") WinWaitActive("Login for SU304001") WinActivate("Login for SU304001") SendKeepActive("Login for SU304001") Send('') EndIf WinWaitActive("Menu browser [User: ", "" ,60) If NOT(WinExists("Menu browser [User: ")) Then msgbox(1,"","No login yet. Program will Exit.") Exit EndIf $BaanDesc= 'mtgxxxpr410001' WinActivate("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}{ENTER}") Sleep(500) $BaanDesc = 'mtgxxxpr410002' SendKeepActive ("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}{ENTER}") SendKeepActive("") Sleep(500) $BaanDesc = 'mtgxxxpr410022' SendKeepActive ("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") ;need to add enter SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}") Sleep(500) SendKeepActive("") Sleep(1000) $BaanDesc = 'tdilc1414m00' WinActivate("Menu browser [User: ") SendKeepActive ("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}") SendKeepActive("") Sleep(500) Send('{ENTER}') WinActive('tdilc1414m00') WinWaitActive('tdilc1414m00') Send('{ENTER}') sleep(500) Send('{DOWN 4}{ENTER}') Sleep(500) WinWaitActive("ttstpsplopen : Select Device [000]") WinActivate("ttstpsplopen : Select Device [000]") SendKeepActive("ttstpsplopen : Select Device [000]") ClipPut("") While ClipGet() <> "EBAAN" sleep(100) Send("^e") sleep(100) Send("EBAAN") sleep(100) Send("^e") sleep(100) Send('^c') WEnd sleep(1000) Send("{ENTER}") $fileoutput = false while $fileoutput = false WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") If WinExists ('File in Use') Then Send("{ENTER}") sleep(100) Send("{ENTER}") sleep(100) Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true endif EndIf EndIf If Not WinExists ('File in Use') Then WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true EndIf EndIf EndIf WEnd FileCopy($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt", "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\ILC_INV_DATA " & $YY & $MM & $DD & ".xls", 1) WinClose($BaanDesc ) WinActivate($title1) WinClose($title1) Global $oExcel = _Excel_Open() If @error Then Exit MsgBox(0, "Error", "_Excel_Open returned @error = " & @error & ", @extended = " & @extended) Global $sWorkbook = $sFileSelectFolder &"\ILC_INV_DATA " & $YY & $MM & $DD Global $oWorkbook = _Excel_BookOpen($oExcel, "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\ILC_INV_DATA " & $yy & $mm & $dd & ".xls") If @error Then Exit MsgBox(0, "Error", "_Excel_BookOpen returned @error = " & @error & ", @extended = " & @extended) _Excel_BookSaveAs($oWorkbook, $sWorkbook & ".xlsx", $xlWorkbookDefault,True) If @error Then Exit MsgBox(0, "Error", "_Excel_BookSaveAs returned @error = " & @error & ", @extended = " & @extended) _Excel_BookClose($oWorkbook) If @error Then Exit MsgBox(0, "Error", "_Excel_BookClose returned @error = " & @error & ", @extended = " & @extended) _Excel_Close($oExcel) If @error Then Exit MsgBox(0, "Error", "_Excel_Close returned @error = " & @error & ", @extended = " & @extended) MsgBox ( 0, "status",$reportname[16] & " report complete" ,3 ) EndIf Sleep(10) ;17)ecnomic stock below if $selectedflag[$charcnt] = 17 Or $selectedflag[$charcnt] = 21 Then If WinExists("Menu browser [User: ") then WinActivate("Menu browser [User: ") EndIf If NOT(WinExists("Menu browser [User: ")) then Run($baandir & "bin\bw.exe", $baandir & "bin") WinWaitActive("Login for SU304001") WinActivate("Login for SU304001") SendKeepActive("Login for SU304001") Send('') EndIf WinWaitActive("Menu browser [User: ", "" ,60) If NOT(WinExists("Menu browser [User: ")) Then msgbox(1,"","No login yet. Program will Exit.") Exit EndIf $BaanDesc = 'mtgxxxpr410001' WinActivate("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}{ENTER}") Sleep(500) $BaanDesc = 'mtgxxxpr410002' SendKeepActive ("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}{ENTER}") SendKeepActive("") Sleep(500) $BaanDesc = 'mtgxxxpr410004' SendKeepActive ("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}") Sleep(500) SendKeepActive("") Sleep(500) WinActivate("Menu browser [User: ") SendKeepActive("Menu browser [User: ") Send("!i{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanNo2 & "{ENTER}{ENTER}") WinActive($Baan2) WinWaitActive($Baan2) Send('^z') Sleep(500) Send('^e') Send('between') Sleep(500) Send('{TAB}440000') sleep(500) Send('{TAB}900000') Sleep(500) Send('^y') sleep(500) Send ('^p') sleep(500) WinWaitActive("Reports") SendKeepActive("Reports") Send('{DOWN 5}{ENTER}') Sleep(1000) WinWaitActive("ttstpsplopen : Select Device [000]") WinActivate("ttstpsplopen : Select Device [000]") SendKeepActive("ttstpsplopen : Select Device [000]") ClipPut("") While ClipGet() <> "EBAAN" sleep(100) Send("^e") sleep(100) Send("EBAAN") sleep(100) Send("^e") sleep(100) Send('^c') WEnd sleep(500) Send("{ENTER}") sleep(1000) $fileoutput = false while $fileoutput = false WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") If WinExists ('File in Use') Then Send("{ENTER}") sleep(100) Send("{ENTER}") sleep(100) Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true endif EndIf EndIf If Not WinExists ('File in Use') Then WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true EndIf EndIf EndIf FileCopy($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt", "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\Economic_stock " & $YY & $MM & $DD & ".xls", 1) WinClose('ttstpqbf : Query by Form [108]') WinActivate($Baan2) WinClose($Baan2) WinActivate($title1) WinClose($title1) Global $oExcel = _Excel_Open() If @error Then Exit MsgBox(0, "Error", "_Excel_Open returned @error = " & @error & ", @extended = " & @extended) Global $sWorkbook = $sFileSelectFolder &"\Economic_stock " & $YY & $MM & $DD Global $oWorkbook = _Excel_BookOpen($oExcel, "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\Economic_stock " & $yy & $mm & $dd & ".xls") If @error Then Exit MsgBox(0, "Error", "_Excel_BookOpen returned @error = " & @error & ", @extended = " & @extended) _Excel_BookSaveAs($oWorkbook, $sWorkbook & ".xlsx", $xlWorkbookDefault,True) If @error Then Exit MsgBox(0, "Error", "_Excel_BookSaveAs returned @error = " & @error & ", @extended = " & @extended) _Excel_BookClose($oWorkbook) If @error Then Exit MsgBox(0, "Error", "_Excel_BookClose returned @error = " & @error & ", @extended = " & @extended) _Excel_Close($oExcel) If @error Then Exit MsgBox(0, "Error", "_Excel_Close returned @error = " & @error & ", @extended = " & @extended) MsgBox ( 0, "status",$reportname[17] & " report complete" ,3 ) WEnd EndIf sleep(10) ;18) Pro Closing Monitoring Report_ All if $selectedflag[$charcnt] = 18 Or $selectedflag[$charcnt] = 21 Then If WinExists("Menu browser [User: ") then WinActivate("Menu browser [User: ") EndIf If NOT(WinExists("Menu browser [User: ")) then Run($baandir & "bin\bw.exe", $baandir & "bin") WinWaitActive("Login for SU304001") WinActivate("Login for SU304001") SendKeepActive("Login for SU304001") Send('') EndIf WinWaitActive("Menu browser [User: ", "" ,60) If NOT(WinExists("Menu browser [User: ")) Then msgbox(1,"","No login yet. Program will Exit.") Exit EndIf $BaanDesc= 'mtgxxxpr410001' WinActivate("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}{ENTER}") Sleep(500) $BaanDesc = 'mtgxxxpr410002' SendKeepActive ("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}{ENTER}") SendKeepActive("") Sleep(500) $BaanDesc = 'mtgxxxpr410007' SendKeepActive ('Menu browser [User: ') Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}") Sleep(500) SendKeepActive("") Sleep(100) ;searches for specfic file WinActivate("Menu browser [User: ") SendKeepActive("Menu browser [User: ") Send("!i{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanNo & "{ENTER}{ENTER}") WinActive ($Baan) WinWaitActive($Baan) Sleep(500) Send( ' '& '{TAB}' ) ;add $project from and to here Sleep(500) Send('{TAB}{TAB}') Send('finished') Sleep(500) Send('{TAB 13}31122900{TAB 2}31122900{TAB 4}{ENTER}') sleep(500) Send ('{DOWN}{ENTER}') WinWaitActive("ttstpsplopen : Select Device [000]") WinActivate("ttstpsplopen : Select Device [000]") SendKeepActive("ttstpsplopen : Select Device [000]") ClipPut("") While ClipGet() <> "EBAAN" sleep(100) Send("^e") sleep(100) Send("EBAAN") sleep(100) Send("^e") sleep(100) Send('^c') WEnd sleep(500) Send("{ENTER}") sleep(100) $fileoutput = false while $fileoutput = false WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") If WinExists ('File in Use') Then Send("{ENTER}") sleep(100) Send("{ENTER}") sleep(100) Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true endif EndIf EndIf If Not WinExists ('File in Use') Then WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true EndIf EndIf EndIf WEnd FileCopy($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt", "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\Project_closing_monitoring " & $YY & $MM & $DD & ".xls", 1) WinActivate($title1) WinClose($title1) WinClose($Baan) Global $oExcel = _Excel_Open() If @error Then Exit MsgBox(0, "Error", "_Excel_Open returned @error = " & @error & ", @extended = " & @extended) Global $sWorkbook = $sFileSelectFolder &"\Project_closing_monitoring " & $YY & $MM & $DD Global $oWorkbook = _Excel_BookOpen($oExcel, "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\Project_closing_monitoring " & $yy & $mm & $dd & ".xls") If @error Then Exit MsgBox(0, "Error", "_Excel_BookOpen returned @error = " & @error & ", @extended = " & @extended) _Excel_BookSaveAs($oWorkbook, $sWorkbook & ".xlsx", $xlWorkbookDefault,True) If @error Then Exit MsgBox(0, "Error", "_Excel_BookSaveAs returned @error = " & @error & ", @extended = " & @extended) _Excel_BookClose($oWorkbook) If @error Then Exit MsgBox(0, "Error", "_Excel_BookClose returned @error = " & @error & ", @extended = " & @extended) _Excel_Close($oExcel) If @error Then Exit MsgBox(0, "Error", "_Excel_Close returned @error = " & @error & ", @extended = " & @extended) MsgBox ( 0, "status",$reportname[18] & " report complete" ,3 ) EndIf Sleep(10) ;19)Pro Closing Report_ All if $selectedflag[$charcnt] = 19 Or $selectedflag[$charcnt] = 21 Then If WinExists("Menu browser [User: ") then WinActivate("Menu browser [User: ") EndIf If NOT(WinExists("Menu browser [User: ")) then Run($baandir & "bin\bw.exe", $baandir & "bin") WinWaitActive("Login for SU304001") WinActivate("Login for SU304001") SendKeepActive("Login for SU304001") Send('') EndIf WinWaitActive("Menu browser [User: ", "" ,120) If NOT(WinExists("Menu browser [User: ")) Then msgbox(1,"","No login yet. Program will Exit.") Exit EndIf $BaanDesc= 'mtgxxxpr410001' WinActivate("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}{ENTER}") Sleep(500) $BaanDesc = 'mtgxxxpr410002' SendKeepActive ("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}{ENTER}") SendKeepActive("") Sleep(500) $BaanDesc = 'mtgxxxpr410007' SendKeepActive ('Menu browser [User: ') Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}") Sleep(500) SendKeepActive("") Sleep(100) ;searches for specfic file WinActivate("Menu browser [User: ") SendKeepActive("Menu browser [User: ") Send("!i{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanNo & "{ENTER}{ENTER}") WinActive ($Baan) WinWaitActive($Baan) Sleep(500) Send( ' '& '{TAB}' ) ;add $project from and to here Sleep(500) Send('{TAB}{TAB}') Sleep(500) Send('Finished') Sleep(500) Send('{TAB 13}31122900{TAB 2}') sleep(500) send('31122900{TAB 4}{ENTER}') WinActive('Reports') Send('{DOWN}{DOWN}{DOWN}{DOWN}{ENTER}') Sleep(500) WinWaitActive("ttstpsplopen : Select Device [000]") WinActivate("ttstpsplopen : Select Device [000]") SendKeepActive("ttstpsplopen : Select Device [000]") ClipPut("") While ClipGet() <> "EBAAN" sleep(100) Send("^e") sleep(100) Send("EBAAN") sleep(100) Send("^e") sleep(100) Send('^c') WEnd sleep(100) Send("{ENTER}") sleep(1000) $fileoutput = false while $fileoutput = false WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") If WinExists ('File in Use') Then Send("{ENTER}") sleep(100) Send("{ENTER}") sleep(100) Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true endif EndIf EndIf If Not WinExists ('File in Use') Then WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true EndIf EndIf EndIf WEnd FileCopy($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt", "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\Project_closing_warehouse " & $YY & $MM & $DD & ".xls", 1) WinClose($Baan) WinActivate($title1) WinClose($title1) Global $oExcel = _Excel_Open() If @error Then Exit MsgBox(0, "Error", "_Excel_Open returned @error = " & @error & ", @extended = " & @extended) Global $sWorkbook = $sFileSelectFolder &"\Project_closing_warehouse " & $YY & $MM & $DD Global $oWorkbook = _Excel_BookOpen($oExcel, "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\Project_closing_warehouse " & $yy & $mm & $dd & ".xls") If @error Then Exit MsgBox(0, "Error", "_Excel_BookOpen returned @error = " & @error & ", @extended = " & @extended) _Excel_BookSaveAs($oWorkbook, $sWorkbook & ".xlsx", $xlWorkbookDefault,True) If @error Then Exit MsgBox(0, "Error", "_Excel_BookSaveAs returned @error = " & @error & ", @extended = " & @extended) _Excel_BookClose($oWorkbook) If @error Then Exit MsgBox(0, "Error", "_Excel_BookClose returned @error = " & @error & ", @extended = " & @extended) _Excel_Close($oExcel) If @error Then Exit MsgBox(0, "Error", "_Excel_Close returned @error = " & @error & ", @extended = " & @extended) MsgBox ( 0, "status",$reportname[19] & " report complete" ,3 ) EndIf Sleep(10) ;20)Pending IQA if $selectedflag[$charcnt] = 20 Or $selectedflag[$charcnt] = 21 Then If WinExists("Menu browser [User: ") then WinActivate("Menu browser [User: ") EndIf If NOT(WinExists("Menu browser [User: ")) then Run($baandir & "bin\bw.exe", $baandir & "bin") WinWaitActive("Login for SU304001") WinActivate("Login for SU304001") SendKeepActive("Login for SU304001") Send('') EndIf WinWaitActive("Menu browser [User: ", "" ,60) If NOT(WinExists("Menu browser [User: ")) Then msgbox(1,"","No login yet. Program will Exit.") Exit EndIf $BaanDesc= 'mtgxxxpr410001' WinActivate("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}{ENTER}") Sleep(500) $BaanDesc = 'mtgxxxpr410002' SendKeepActive ("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}{ENTER}") SendKeepActive("") Sleep(500) $BaanDesc = 'mtgxxxpr410011' SendKeepActive ('Menu browser [User: ') Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}") Sleep(500) SendKeepActive("") Sleep(100) $BaanDesc = 'tipcs7461m000' WinActivate("Menu browser [User: ") SendKeepActive ("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}") SendKeepActive("") Sleep(500) Send('{ENTER}') WinActive('tipcs7461m000') WinWaitActive('tipcs7461m000') send(' {TAB}{TAB}{ENTER}') Sleep(500) send('{DOWN 5}{UP}{ENTER}') Sleep(500) WinWaitActive("ttstpsplopen : Select Device [000]") WinActivate("ttstpsplopen : Select Device [000]") SendKeepActive("ttstpsplopen : Select Device [000]") ClipPut("") While ClipGet() <> "EBAAN" sleep(100) Send("^e") sleep(100) Send("EBAAN") sleep(100) Send("^e") sleep(100) Send('^c') WEnd sleep(100) Send("{ENTER}") sleep(1000) $fileoutput = false while $fileoutput = false WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") If WinExists ('File in Use') Then Send("{ENTER}") sleep(100) Send("{ENTER}") sleep(100) Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true endif EndIf EndIf If Not WinExists ('File in Use') Then WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true EndIf EndIf EndIf WEnd FileCopy($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt", "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\Pending_IQA " & $YY & $MM & $DD & ".xls", 1) WinClose('tipcs7461m000') WinActivate($title1) WinClose($title1) Global $oExcel = _Excel_Open() If @error Then Exit MsgBox(0, "Error", "_Excel_Open returned @error = " & @error & ", @extended = " & @extended) Global $sWorkbook = $sFileSelectFolder &"\Pending_IQA " & $YY & $MM & $DD Global $oWorkbook = _Excel_BookOpen($oExcel, "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\Pending_IQA " & $yy & $mm & $dd & ".xls") If @error Then Exit MsgBox(0, "Error", "_Excel_BookOpen returned @error = " & @error & ", @extended = " & @extended) _Excel_BookSaveAs($oWorkbook, $sWorkbook & ".xlsx", $xlWorkbookDefault,True) If @error Then Exit MsgBox(0, "Error", "_Excel_BookSaveAs returned @error = " & @error & ", @extended = " & @extended) _Excel_BookClose($oWorkbook) If @error Then Exit MsgBox(0, "Error", "_Excel_BookClose returned @error = " & @error & ", @extended = " & @extended) _Excel_Close($oExcel) If @error Then Exit MsgBox(0, "Error", "_Excel_Close returned @error = " & @error & ", @extended = " & @extended) MsgBox ( 0, "status",$reportname[20] & " report complete" ,3 ) EndIf sleep(10) MsgBox ( 0, "status",$reportname[21] & " report complete" ,3 ) ;21)all reports (Except 3 and 5) ;----------------------------------------------------------------------------------------------------------------------------------------------------------------- ;22)range PRP Pur if $selectedflag[$charcnt] = 22 then If WinExists("Menu browser [User: ") then WinActivate("Menu browser [User: ") EndIf If NOT(WinExists("Menu browser [User: ")) then Run($baandir & "bin\bw.exe", $baandir & "bin") WinWaitActive("Login for SU304001") WinActivate("Login for SU304001") SendKeepActive("Login for SU304001") Send('') EndIf WinWaitActive("Menu browser [User: ", "" ,60) If NOT(WinExists("Menu browser [User: ")) Then msgbox(1,"","No login yet. Program will Exit.") Exit EndIf $BaanDesc= 'mtgxxxlo040001' WinActivate("Menu browser [User: ") Send("!i{DOWN}{ENTER}") Sleep(500) WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}") Sleep(500) $BaanDesc = 'mtgxxxlo040007' SendKeepActive ("Menu browser [User: ") Sleep(500) Send("!i{DOWN}{ENTER}") Sleep(500) WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}") SendKeepActive("") sleep(500) $BaanDesc = 'tccomlog01001' SendKeepActive ("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}") SendKeepActive("") Sleep(500) Send('{ENTER}') WinWaitActive('Queries Logistics employee') Send('{DOWN 4}{ENTER}') Sleep(1500) Global $projectfrom1 $projectfrom1= InputBox('project from','please write the project no') Global $projectto $projectto= InputBox('project to','please write the project no') WinWaitActive('ttadv3480m000') Send($projectfrom1 & '{DOWN}'& $projectto & '{DOWN 2}' ) sleep(500) Send('confirmed') sleep(500) Send('{DOWN}{RIGHT 12}') Sleep(200) Send('1900'&'{DOWN}{RIGHT 12}' &'2900' & '{DOWN 5}{A}{DOWN 4}{Y}') Sleep(500) WinWaitActive("ttstpsplopen : Select Device [000]") WinActivate("ttstpsplopen : Select Device [000]") SendKeepActive("ttstpsplopen : Select Device [000]") ClipPut("") While ClipGet() <> "EBAAN" sleep(100) Send("^e") sleep(100) Send("EBAAN") sleep(100) Send("^e") sleep(100) Send('^c') WEnd Sleep(500) Send("{ENTER}") WinClose('tccompro03001 : Queries Project Monitoring (M&S) [108]') Sleep(1000) $fileoutput = false while $fileoutput = false WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") If WinExists ('File in Use') Then Send("{ENTER}") sleep(100) Send("{ENTER}") sleep(100) Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true endif EndIf EndIf If Not WinExists ('File in Use') Then WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true EndIf EndIf EndIf FileCopy($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt", "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\range_PRP_Purchase " & $YY & $MM & $DD & ".xls", 1) WinClose('tccompro03001 : Queries Project Monitoring (M&S) [108]') WinActivate($title1) WinClose($title1) if $selectedflag[$charcnt] = 22 Then Global $oExcel = _Excel_Open() If @error Then Exit MsgBox(0, "Error", "_Excel_Open returned @error = " & @error & ", @extended = " & @extended) Global $sWorkbook = $sFileSelectFolder &"\range_PRP_Purchase " & $YY & $MM & $DD Global $oWorkbook = _Excel_BookOpen($oExcel, "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\range_PRP_Purchase " & $yy & $mm & $dd & ".xls") If @error Then Exit MsgBox(0, "Error", "_Excel_BookOpen returned @error = " & @error & ", @extended = " & @extended) _Excel_BookSaveAs($oWorkbook, $sWorkbook & ".xlsx", $xlWorkbookDefault,True) If @error Then Exit MsgBox(0, "Error", "_Excel_BookSaveAs returned @error = " & @error & ", @extended = " & @extended) _Excel_BookClose($oWorkbook) If @error Then Exit MsgBox(0, "Error", "_Excel_BookClose returned @error = " & @error & ", @extended = " & @extended) _Excel_Close($oExcel) If @error Then Exit MsgBox(0, "Error", "_Excel_Close returned @error = " & @error & ", @extended = " & @extended) MsgBox ( 0, "status",$reportname[22] & " report complete" ,3 ) EndIf WEnd EndIf Sleep(10) ;23)ecnomic stock below(TEST AGAIN) if $selectedflag[$charcnt] = 23 then If WinExists("Menu browser [User: ") then WinActivate("Menu browser [User: ") EndIf If NOT(WinExists("Menu browser [User: ")) then Run($baandir & "bin\bw.exe", $baandir & "bin") WinWaitActive("Login for SU304001") WinActivate("Login for SU304001") SendKeepActive("Login for SU304001") Send('') EndIf WinWaitActive("Menu browser [User: ", "" ,60) If NOT(WinExists("Menu browser [User: ")) Then msgbox(1,"","No login yet. Program will Exit.") Exit EndIf $BaanDesc= 'mtgxxxpr410001' WinActivate("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}{ENTER}") Sleep(500) $BaanDesc = 'mtgxxxpr410002' SendKeepActive ("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}{ENTER}") ;still need to add mouse click SendKeepActive("") Sleep(500) $BaanDesc = 'mtgxxxpr410004' SendKeepActive ("Menu browser [User: ") Send("!i{DOWN}{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanDesc & "{ENTER}{ENTER}") Sleep(500) SendKeepActive("") Sleep(500) WinActivate("Menu browser [User: ") SendKeepActive("Menu browser [User: ") Send("!i{ENTER}") WinWaitActive("ttdsk1300m000 : Browser Data Entry [000]") SendKeepActive("ttdsk1300m000 : Browser Data Entry [000]") Send($BaanNo2 & "{ENTER}{ENTER}") WinActive($Baan2) WinWaitActive($Baan2) Send('^z') Sleep(500) Send('^e') Send('between') Sleep(500) Global $projectfrom1 $projectfrom1= InputBox('project from','please write the project no') Global $projectto $projectto= InputBox('project to','please write the project no') sleep(500) Send('{TAB}'& $projectfrom1) Send('{TAB}'& $projectto) Sleep(500) Send('^y') sleep(500) Send ('^p') sleep(500) WinWaitActive("Reports") SendKeepActive("Reports") Send('{DOWN 5}{ENTER}') Sleep(500) WinWaitActive("ttstpsplopen : Select Device [000]") WinActivate("ttstpsplopen : Select Device [000]") SendKeepActive("ttstpsplopen : Select Device [000]") ClipPut("") While ClipGet() <> "EBAAN" sleep(100) Send("^e") sleep(100) Send("EBAAN") sleep(100) Send("^e") sleep(100) Send('^c') WEnd sleep(500) Send("{ENTER}") sleep(1000) $fileoutput = false while $fileoutput = false WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") If WinExists ('File in Use') Then Send("{ENTER}") sleep(100) Send("{ENTER}") sleep(100) Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true endif EndIf EndIf If Not WinExists ('File in Use') Then WinActive("Microsoft Excel") WinWaitActive("Microsoft Excel") Send("{ENTER}") WinWaitActive("Microsoft Excel - tmp") $title1 = WinGetTitle("Microsoft Excel - tmp", "") if fileexists($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt") then $filetime = filegettime ($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt",1,1) if $filetime > $nowtime then $fileoutput = true EndIf EndIf EndIf FileCopy($baantmpdir & "tmp\" & StringMid($title1,19,12) & ".txt", "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\range_Economic_stock " & $YY & $MM & $DD & ".xls", 1) WinClose('ttstpqbf : Query by Form [108]') WinActivate($Baan2) WinClose($Baan2) WinActivate($title1) WinClose($title1) if $selectedflag[$charcnt] = 23 Then ;if running sepereatly Global $oExcel = _Excel_Open() If @error Then Exit MsgBox(0, "Error", "_Excel_Open returned @error = " & @error & ", @extended = " & @extended) Global $sWorkbook = $sFileSelectFolder &"\range_Economic_stock " & $YY & $MM & $DD Global $oWorkbook = _Excel_BookOpen($oExcel, "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\range_Economic_stock " & $yy & $mm & $dd & ".xls") If @error Then Exit MsgBox(0, "Error", "_Excel_BookOpen returned @error = " & @error & ", @extended = " & @extended) _Excel_BookSaveAs($oWorkbook, $sWorkbook & ".xlsx", $xlWorkbookDefault,True) If @error Then Exit MsgBox(0, "Error", "_Excel_BookSaveAs returned @error = " & @error & ", @extended = " & @extended) _Excel_BookClose($oWorkbook) If @error Then Exit MsgBox(0, "Error", "_Excel_BookClose returned @error = " & @error & ", @extended = " & @extended) _Excel_Close($oExcel) If @error Then Exit MsgBox(0, "Error", "_Excel_Close returned @error = " & @error & ", @extended = " & @extended) MsgBox ( 0, "status",$reportname[23] & " report complete" ,3 ) EndIf WEnd EndIf sleep(10) EndSwitch ;24) Run macro compile for range prp pur and economic stock if $selectedflag[$charcnt] = 24 then $oExcel = ObjCreate("Excel.Application") ; Create an Excel Object $oExcel.Visible = 1 ; Let Excel show itself $oExcel.Workbooks.Open('J:\OPS\OPS_Share\Planners\7 - Automation\AutoIt reports.XLSM',0) $oExcel.ActiveWorkbook.Application.Run("ECONOMICSTOCKCOMPILE") EndIf Sleep(10) ;25) delete .xls files if $selectedflag[$charcnt] = 25 Then $dir = "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files" DirRemove($dir,1) DirCreate($dir) EndIf $charcnt = $charcnt + 1 WEnd ;if $Baan_exist = 0 then ; WinClose("Menu browser [User: ") ;EndIf