lolipop Posted March 14, 2013 Posted March 14, 2013 Hi, Can anyone advise me why my excel process doesn't close after clicking button 2 even after I state in the code to close the excel process. Btw, need to create a temp.xls file in the script directory. Thanks. expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <Date.au3> #include <Excel.au3> #include <ListViewConstants.au3> #include <Array.au3> #include <GuiListView.au3> Global $CurrentTime = @HOUR&":"&@MIN;&":"&@SEC Global $CurrentDate = @YEAR&"/"&@MON&"/"&@MDAY Global $ExcelSignOutArray[3] = [$CurrentDate, $CurrentTime, "Sign-Out"] Global $ExcelSignOutArrayWRemark[4] = [$CurrentDate, $CurrentTime, "Sign-Out", "System Auto Sign-Out"] Global $sFilePath = @ScriptDir & "\temp.xls" Create_Form1() Func Create_Form1() $Form1 = GUICreate("XXX", 485, 531, -1, -1) GUISetBkColor(0xFFFFFF) $Form1_Graphic1 = GUICtrlCreateGraphic(0, 0, 490, 161) GUICtrlSetBkColor(-1, 0x9BBB58) $Form1_Label1 = GUICtrlCreateLabel("XXX", 40, 40, 218, 52) GUICtrlSetFont(-1, 27, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFFFBF0) GUICtrlSetBkColor(-1, 0x9BBB58) $Form1_Label2 = GUICtrlCreateLabel("XXX", 40, 72, 268, 52) GUICtrlSetFont(-1, 27, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFFFBF0) GUICtrlSetBkColor(-1, 0x9BBB58) $Form1_Label3 = GUICtrlCreateLabel("XXX", 98, 200, 289, 33) GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif") $Form1_Label4 = GUICtrlCreateLabel("XXX", 64, 296, 151, 20) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $Form1_Label5 = GUICtrlCreateLabel("XXX", 64, 320, 154, 20) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $Form1_Label6 = GUICtrlCreateLabel("XXX", 64, 416, 160, 20) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $Form1_Label7 = GUICtrlCreateLabel("XXX", 64, 440, 106, 20) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $Form1_Button1 = GUICtrlCreateButton("Button1", 236, 292, 201, 45, $BS_BITMAP) $Form1_Button2 = GUICtrlCreateButton("Button2", 236, 416, 201, 45, $BS_BITMAP) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE $Form1_Result1 = MsgBox(52,"", "Are you sure you want to exit?") If $Form1_Result1 = 6 Then Exit Case $msg = $Form1_Button1 GUIDelete($Form1) Create_Form2() ExitLoop Case $msg = $Form1_Button2 GUIDelete($Form1) Global $oExcel = _ExcelBookOpen($sFilePath,0) ExcelFindLastRow() Global $ConcatVal = "Sign-In" Global $aFound = _ExcelFindInRange($oExcel, $ConcatVal, "L1:L"&$iLastRow) ;Found the total number of row with $ConcatVal keyword Global $TotalSignIn = $aFound[0][0] $i = 1 While $i <= $TotalSignIn Global $SelectedRow = $aFound[$i][3] Global $AutoSignOutDateDiffData = _ExcelReadArray($oExcel, $SelectedRow, 1, 13, 0);The individual column data respective to $TotalSignIn $ConvertYear = StringMid ($AutoSignOutDateDiffData[7], 1, 4) $ConvertMonth = StringMid ($AutoSignOutDateDiffData[7], 5, 2) $ConvertDate = StringMid ($AutoSignOutDateDiffData[7], 7, 2) $CombineDate = $ConvertYear&"/"&$ConvertMonth&"/"&$ConvertDate $AutoSignOutDateDiff = _DateDiff("D", $CombineDate, _NowCalcDate()) If $AutoSignOutDateDiff >= 1 Then _ExcelWriteArray($oExcel, ($aFound[$i][3]), 10, $ExcelSignOutArrayWRemark, 0) EndIf $i = $i + 1 WEnd _ExcelBookClose($oExcel,1) Create_Form3() ExitLoop EndSelect WEnd EndFunc Func Create_Form3() $Form3 = GUICreate("X", 485, 531, -1, -1) GUISetBkColor(0xFFFFFF) $Form3_Graphic1 = GUICtrlCreateGraphic(0, 0, 490, 161) GUICtrlSetBkColor(-1, 0x9BBB58) $Form3_Label1 = GUICtrlCreateLabel("X", 40, 40, 218, 52) GUICtrlSetFont(-1, 27, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFFFBF0) GUICtrlSetBkColor(-1, 0x9BBB58) $Form3_Label2 = GUICtrlCreateLabel("X", 40, 72, 268, 52) GUICtrlSetFont(-1, 27, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFFFBF0) GUICtrlSetBkColor(-1, 0x9BBB58) Global $Form3_ListView1 = GUICtrlCreateListView("1|2|3|4|5", 0, 161, 485, 250, BitOR($GUI_SS_DEFAULT_LISTVIEW,$LVS_SINGLESEL,$LVS_NOSORTHEADER), $LVS_EX_FULLROWSELECT) GUICtrlSetFont(-1, 9, 800, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, $GUI_BKCOLOR_LV_ALTERNATE) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 35) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 130) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 90) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 130) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 4, 100) $Form3_Button4 = GUICtrlCreateButton("Button4", 145, 420, 201, 45, $BS_BITMAP) $Form3_Button3 = GUICtrlCreateButton("Button3", 8, 496, 73, 30, $BS_BITMAP) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE $Form3__Result1 = MsgBox(52,"", "Are you sure you want to exit?") If $Form3__Result1 = 6 Then Exit Case $Form3_Button4 GUIDelete($Form3) Create_Form1() ExitLoop Case $Form3_Button3 GUIDelete($Form3) Create_Form1() ExitLoop EndSwitch WEnd EndFunc Func ExcelFindLastRow() $oExcel1 = ObjGet($sFilePath, "Excel.Application") $oSheet = $oExcel1.ActiveSheet Global $iLastRow = $oSheet.Cells.Find('*', $oSheet.Cells(1, 1), Default, Default, 1, 2).Row EndFunc Func _ExcelFindInRange($oExcel, $sFindWhat, $sRangeOrRowStart, $iColStart = 1, $iRowEnd = 1, $iColEnd = 1, $iDataType = 0, $iWholeOrPart = 2, $fMatchCase = False, $fMatchFormat = "") Local $iCount, $sA1, $sR1C1, $sFound, $Temp1, $Temp2, $sFirst If NOT IsObj($oExcel) Then Return SetError(1, 0, 0) If $iDataType <> 0 Then If $iDataType <> -4163 Or $iDataType <> -4123 Or $iDataType <> -4144 Then Return SetError(4, 0, 0) EndIf EndIf If $iWholeOrPart < 1 Or $iWholeOrPart > 2 Then Return SetError(5, 0, 0) If NOT StringRegExp($sRangeOrRowStart, "[A-Z,a-z]", 0) Then If $sRangeOrRowStart < 1 Then Return SetError(2, 0, 0) If $iColStart < 1 Then Return SetError(2, 1, 0) If $iRowEnd < $sRangeOrRowStart Then Return SetError(3, 0, 0) If $iColEnd < $iColStart Then Return SetError(3, 1, 0) $oExcel.Range($oExcel.Cells($sRangeOrRowStart, $iColStart), $oExcel.Cells($iRowEnd, $iColEnd)).Select Else $oExcel.Range($sRangeOrRowStart).Select EndIf If $iDataType = 0 Then If $fMatchFormat = "" Then $oFound = $oExcel.Selection.Find($sFindWhat, $oExcel.ActiveCell, Default, $iWholeOrPart, Default, Default, $fMatchCase, Default) Else $oFound = $oExcel.Selection.Find($sFindWhat, $oExcel.ActiveCell, Default, $iWholeOrPart, Default, Default, $fMatchCase, Default, $fMatchFormat) EndIf Else If $fMatchFormat = "" Then $oFound = $oExcel.Selection.Find($sFindWhat, $oExcel.ActiveCell, $iDataType, $iWholeOrPart, Default, Default, $fMatchCase, Default) Else $oFound = $oExcel.Selection.Find($sFindWhat, $oExcel.ActiveCell, $iDataType, $iWholeOrPart, Default, Default, $fMatchCase, Default, $fMatchFormat) EndIf EndIf If IsObj($oFound) Then $oFound.Activate Else Local $aFound[1][1] $aFound[0][0] = 0 Return $aFound EndIf While 1 If $iCount > 0 And $iCount < 2 Then $sFirst = $sA1 $Temp1 = $oExcel.ActiveCell.Address $Temp2 = $oExcel.ActiveCell.Address(True, True, $xlR1C1) If $Temp1 = $sFirst Then ExitLoop If $iCount > 0 Then $sA1 = $sA1 & "*" & $Temp1 $sR1C1 = $sR1C1 & "*" & $Temp2 Else $sA1 = $Temp1 $sR1C1 = $Temp2 EndIf $iCount += 1 $oExcel.Selection.FindNext($oExcel.ActiveCell).Activate WEnd Local $aFound[$iCount + 1][4] $sA1 = StringReplace($sA1, "$", "") Local $aA1 = StringSplit($sA1, "*") Local $aR1C1 = StringSplit($sR1C1, "*") $aFound[0][0] = $iCount For $xx = 1 To $iCount $aFound[$xx][0] = $aA1[$xx] $aFound[$xx][1] = $aR1C1[$xx] $Temp1 = StringRegExp($aR1C1[$xx], "[RZ]([^CS]*)[CS](.*)",3) $aFound[$xx][2] = Number($Temp1[1]) $aFound[$xx][3] = Number($Temp1[0]) Next Return $aFound _ExcelBookClose($oExcel, 1, 0) EndFunc
nitekram Posted March 14, 2013 Posted March 14, 2013 (edited) I do not have excel on this computer, but can you put a msgbox after the close to find out what the @error might be? If @error Then MsgBox('','ERROR',@error) Edited March 14, 2013 by nitekram 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator
lolipop Posted March 14, 2013 Author Posted March 14, 2013 Thanks nitekram, Added the msgbox but there's no error message at all. It seems to exceute the proceed along.
nitekram Posted March 14, 2013 Posted March 14, 2013 (edited) Does it created the next GUI ie. Create_Form3(), if not - exit your loop first and then at the bottom call the function: expandcollapse popupFunc Create_Form1() $Form1 = GUICreate("XXX", 485, 531, -1, -1) GUISetBkColor(0xFFFFFF) $Form1_Graphic1 = GUICtrlCreateGraphic(0, 0, 490, 161) GUICtrlSetBkColor(-1, 0x9BBB58) $Form1_Label1 = GUICtrlCreateLabel("XXX", 40, 40, 218, 52) GUICtrlSetFont(-1, 27, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFFFBF0) GUICtrlSetBkColor(-1, 0x9BBB58) $Form1_Label2 = GUICtrlCreateLabel("XXX", 40, 72, 268, 52) GUICtrlSetFont(-1, 27, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFFFBF0) GUICtrlSetBkColor(-1, 0x9BBB58) $Form1_Label3 = GUICtrlCreateLabel("XXX", 98, 200, 289, 33) GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif") $Form1_Label4 = GUICtrlCreateLabel("XXX", 64, 296, 151, 20) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $Form1_Label5 = GUICtrlCreateLabel("XXX", 64, 320, 154, 20) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $Form1_Label6 = GUICtrlCreateLabel("XXX", 64, 416, 160, 20) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $Form1_Label7 = GUICtrlCreateLabel("XXX", 64, 440, 106, 20) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $Form1_Button1 = GUICtrlCreateButton("Button1", 236, 292, 201, 45, $BS_BITMAP) $Form1_Button2 = GUICtrlCreateButton("Button2", 236, 416, 201, 45, $BS_BITMAP) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE $Form1_Result1 = MsgBox(52, "", "Are you sure you want to exit?") If $Form1_Result1 = 6 Then Exit Case $msg = $Form1_Button1 GUIDelete($Form1) Create_Form2() ExitLoop Case $msg = $Form1_Button2 GUIDelete($Form1) Global $oExcel = _ExcelBookOpen($sFilePath, 0) ExcelFindLastRow() Global $ConcatVal = "Sign-In" Global $aFound = _ExcelFindInRange($oExcel, $ConcatVal, "L1:L" & $iLastRow) ;Found the total number of row with $ConcatVal keyword Global $TotalSignIn = $aFound[0][0] $i = 1 While $i <= $TotalSignIn Global $SelectedRow = $aFound[$i][3] Global $AutoSignOutDateDiffData = _ExcelReadArray($oExcel, $SelectedRow, 1, 13, 0);The individual column data respective to $TotalSignIn $ConvertYear = StringMid($AutoSignOutDateDiffData[7], 1, 4) $ConvertMonth = StringMid($AutoSignOutDateDiffData[7], 5, 2) $ConvertDate = StringMid($AutoSignOutDateDiffData[7], 7, 2) $CombineDate = $ConvertYear & "/" & $ConvertMonth & "/" & $ConvertDate $AutoSignOutDateDiff = _DateDiff("D", $CombineDate, _NowCalcDate()) If $AutoSignOutDateDiff >= 1 Then _ExcelWriteArray($oExcel, ($aFound[$i][3]), 10, $ExcelSignOutArrayWRemark, 0) EndIf $i = $i + 1 WEnd _ExcelBookClose($oExcel, 1) ;Create_Form3() ExitLoop EndSelect WEnd Create_Form3() EndFunc ;==>Create_Form1 I might be off base here, as your stating in your first post that Excel is not closing - so everything else is going as planned? EDIT Try this too, maybe you are not seeing the prompt to save??? _ExcelBookClose($oExcel, 1, 1) might be getting tired, sorry -change it to a 1 to see the prompt Edited March 14, 2013 by nitekram 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator
lolipop Posted March 14, 2013 Author Posted March 14, 2013 yes it does create the next gui form3. As I mention, it seems to process the _excelbookclose successfully but when I open the task manager and look, the Excel.exe process is still there.
nitekram Posted March 14, 2013 Posted March 14, 2013 Oh, I misunderstood everything. Without excel I am not going to be able to tell what is going on, but you could kill the process within your script? I know @water will be able to answer, but he is not online 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator
nitekram Posted March 14, 2013 Posted March 14, 2013 (edited) Just to make sure, can you verify before the script runs that there are no process for excel opened? and put a msgbox, right before you close to check how many are running at that time edit - stupid keyboard does not know how to type EDIT - he (@water) will also need to know which version of excel you are running Edited March 14, 2013 by nitekram 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator
4gotn1 Posted March 14, 2013 Posted March 14, 2013 (edited) expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <Date.au3> #include <Excel.au3> #include <ListViewConstants.au3> #include <Array.au3> #include <GuiListView.au3> Global $CurrentTime = @HOUR&":"&@MIN;&":"&@SEC Global $CurrentDate = @YEAR&"/"&@MON&"/"&@MDAY Global $ExcelSignOutArray[3] = [$CurrentDate, $CurrentTime, "Sign-Out"] Global $ExcelSignOutArrayWRemark[4] = [$CurrentDate, $CurrentTime, "Sign-Out", "System Auto Sign-Out"] Global $sFilePath = @ScriptDir & "\temp.xls" Create_Form1() Func Create_Form1() $Form1 = GUICreate("XXX", 485, 531, -1, -1) GUISetBkColor(0xFFFFFF) $Form1_Graphic1 = GUICtrlCreateGraphic(0, 0, 490, 161) GUICtrlSetBkColor(-1, 0x9BBB58) $Form1_Label1 = GUICtrlCreateLabel("XXX", 40, 40, 218, 52) GUICtrlSetFont(-1, 27, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFFFBF0) GUICtrlSetBkColor(-1, 0x9BBB58) $Form1_Label2 = GUICtrlCreateLabel("XXX", 40, 72, 268, 52) GUICtrlSetFont(-1, 27, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFFFBF0) GUICtrlSetBkColor(-1, 0x9BBB58) $Form1_Label3 = GUICtrlCreateLabel("XXX", 98, 200, 289, 33) GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif") $Form1_Label4 = GUICtrlCreateLabel("XXX", 64, 296, 151, 20) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $Form1_Label5 = GUICtrlCreateLabel("XXX", 64, 320, 154, 20) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $Form1_Label6 = GUICtrlCreateLabel("XXX", 64, 416, 160, 20) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $Form1_Label7 = GUICtrlCreateLabel("XXX", 64, 440, 106, 20) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $Form1_Button1 = GUICtrlCreateButton("Button1", 236, 292, 201, 45, $BS_BITMAP) $Form1_Button2 = GUICtrlCreateButton("Button2", 236, 416, 201, 45, $BS_BITMAP) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE $Form1_Result1 = MsgBox(52,"", "Are you sure you want to exit?") If $Form1_Result1 = 6 Then Exit Case $msg = $Form1_Button1 GUIDelete($Form1) Create_Form2() ExitLoop Case $msg = $Form1_Button2 GUIDelete($Form1) If ProcessExists("excel.exe") Then ProcessClose("excel.exe") Global $oExcel = _ExcelBookOpen($sFilePath,0) ExcelFindLastRow() Global $ConcatVal = "Sign-In" Global $aFound = _ExcelFindInRange($oExcel, $ConcatVal, "L1:L"&$iLastRow) ;Found the total number of row with $ConcatVal keyword Global $TotalSignIn = $aFound[0][0] $i = 1 While $i <= $TotalSignIn Global $SelectedRow = $aFound[$i][3] Global $AutoSignOutDateDiffData = _ExcelReadArray($oExcel, $SelectedRow, 1, 13, 0);The individual column data respective to $TotalSignIn $ConvertYear = StringMid ($AutoSignOutDateDiffData[7], 1, 4) $ConvertMonth = StringMid ($AutoSignOutDateDiffData[7], 5, 2) $ConvertDate = StringMid ($AutoSignOutDateDiffData[7], 7, 2) $CombineDate = $ConvertYear&"/"&$ConvertMonth&"/"&$ConvertDate $AutoSignOutDateDiff = _DateDiff("D", $CombineDate, _NowCalcDate()) If $AutoSignOutDateDiff >= 1 Then _ExcelWriteArray($oExcel, ($aFound[$i][3]), 10, $ExcelSignOutArrayWRemark, 0) EndIf $i = $i + 1 WEnd _ExcelBookClose($oExcel,1) Create_Form3() ExitLoop EndSelect WEnd EndFunc Func Create_Form3() $Form3 = GUICreate("X", 485, 531, -1, -1) GUISetBkColor(0xFFFFFF) $Form3_Graphic1 = GUICtrlCreateGraphic(0, 0, 490, 161) GUICtrlSetBkColor(-1, 0x9BBB58) $Form3_Label1 = GUICtrlCreateLabel("X", 40, 40, 218, 52) GUICtrlSetFont(-1, 27, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFFFBF0) GUICtrlSetBkColor(-1, 0x9BBB58) $Form3_Label2 = GUICtrlCreateLabel("X", 40, 72, 268, 52) GUICtrlSetFont(-1, 27, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFFFBF0) GUICtrlSetBkColor(-1, 0x9BBB58) Global $Form3_ListView1 = GUICtrlCreateListView("1|2|3|4|5", 0, 161, 485, 250, BitOR($GUI_SS_DEFAULT_LISTVIEW,$LVS_SINGLESEL,$LVS_NOSORTHEADER), $LVS_EX_FULLROWSELECT) GUICtrlSetFont(-1, 9, 800, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, $GUI_BKCOLOR_LV_ALTERNATE) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 35) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 130) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 90) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 130) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 4, 100) $Form3_Button4 = GUICtrlCreateButton("Button4", 145, 420, 201, 45, $BS_BITMAP) $Form3_Button3 = GUICtrlCreateButton("Button3", 8, 496, 73, 30, $BS_BITMAP) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE $Form3__Result1 = MsgBox(52,"", "Are you sure you want to exit?") If $Form3__Result1 = 6 Then Exit Case $Form3_Button4 GUIDelete($Form3) Create_Form1() ExitLoop Case $Form3_Button3 GUIDelete($Form3) Create_Form1() ExitLoop EndSwitch WEnd EndFunc Func ExcelFindLastRow() $oExcel1 = ObjGet($sFilePath, "Excel.Application") $oSheet = $oExcel1.ActiveSheet Global $iLastRow = $oSheet.Cells.Find('*', $oSheet.Cells(1, 1), Default, Default, 1, 2).Row EndFunc Func _ExcelFindInRange($oExcel, $sFindWhat, $sRangeOrRowStart, $iColStart = 1, $iRowEnd = 1, $iColEnd = 1, $iDataType = 0, $iWholeOrPart = 2, $fMatchCase = False, $fMatchFormat = "") Local $iCount, $sA1, $sR1C1, $sFound, $Temp1, $Temp2, $sFirst If NOT IsObj($oExcel) Then Return SetError(1, 0, 0) If $iDataType <> 0 Then If $iDataType <> -4163 Or $iDataType <> -4123 Or $iDataType <> -4144 Then Return SetError(4, 0, 0) EndIf EndIf If $iWholeOrPart < 1 Or $iWholeOrPart > 2 Then Return SetError(5, 0, 0) If NOT StringRegExp($sRangeOrRowStart, "[A-Z,a-z]", 0) Then If $sRangeOrRowStart < 1 Then Return SetError(2, 0, 0) If $iColStart < 1 Then Return SetError(2, 1, 0) If $iRowEnd < $sRangeOrRowStart Then Return SetError(3, 0, 0) If $iColEnd < $iColStart Then Return SetError(3, 1, 0) $oExcel.Range($oExcel.Cells($sRangeOrRowStart, $iColStart), $oExcel.Cells($iRowEnd, $iColEnd)).Select Else $oExcel.Range($sRangeOrRowStart).Select EndIf If $iDataType = 0 Then If $fMatchFormat = "" Then $oFound = $oExcel.Selection.Find($sFindWhat, $oExcel.ActiveCell, Default, $iWholeOrPart, Default, Default, $fMatchCase, Default) Else $oFound = $oExcel.Selection.Find($sFindWhat, $oExcel.ActiveCell, Default, $iWholeOrPart, Default, Default, $fMatchCase, Default, $fMatchFormat) EndIf Else If $fMatchFormat = "" Then $oFound = $oExcel.Selection.Find($sFindWhat, $oExcel.ActiveCell, $iDataType, $iWholeOrPart, Default, Default, $fMatchCase, Default) Else $oFound = $oExcel.Selection.Find($sFindWhat, $oExcel.ActiveCell, $iDataType, $iWholeOrPart, Default, Default, $fMatchCase, Default, $fMatchFormat) EndIf EndIf If IsObj($oFound) Then $oFound.Activate Else Local $aFound[1][1] $aFound[0][0] = 0 Return $aFound EndIf While 1 If $iCount > 0 And $iCount < 2 Then $sFirst = $sA1 $Temp1 = $oExcel.ActiveCell.Address $Temp2 = $oExcel.ActiveCell.Address(True, True, $xlR1C1) If $Temp1 = $sFirst Then ExitLoop If $iCount > 0 Then $sA1 = $sA1 & "*" & $Temp1 $sR1C1 = $sR1C1 & "*" & $Temp2 Else $sA1 = $Temp1 $sR1C1 = $Temp2 EndIf $iCount += 1 $oExcel.Selection.FindNext($oExcel.ActiveCell).Activate WEnd Local $aFound[$iCount + 1][4] $sA1 = StringReplace($sA1, "$", "") Local $aA1 = StringSplit($sA1, "*") Local $aR1C1 = StringSplit($sR1C1, "*") $aFound[0][0] = $iCount For $xx = 1 To $iCount $aFound[$xx][0] = $aA1[$xx] $aFound[$xx][1] = $aR1C1[$xx] $Temp1 = StringRegExp($aR1C1[$xx], "[RZ]([^CS]*)[CS](.*)",3) $aFound[$xx][2] = Number($Temp1[1]) $aFound[$xx][3] = Number($Temp1[0]) Next Return $aFound _ExcelBookClose($oExcel, 1, 0) EndFunc Something like this should kill excel.exe when you hit "Button 2". You'll have to elaborate on the temp.xls however. -Cheers Edited March 14, 2013 by 4gotn1
nitekram Posted March 14, 2013 Posted March 14, 2013 (edited) I might have found it - you open an object for excel in your code? with this function ExcelFindLastRow() edit - easy enough to test on your end - just comment out the call to that function and see if it resolves? edit - sorry, and just hard code last row? Edited March 14, 2013 by nitekram 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator
nitekram Posted March 14, 2013 Posted March 14, 2013 expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <Date.au3> #include <Excel.au3> #include <ListViewConstants.au3> #include <Array.au3> #include <GuiListView.au3> Global $CurrentTime = @HOUR&":"&@MIN;&":"&@SEC Global $CurrentDate = @YEAR&"/"&@MON&"/"&@MDAY Global $ExcelSignOutArray[3] = [$CurrentDate, $CurrentTime, "Sign-Out"] Global $ExcelSignOutArrayWRemark[4] = [$CurrentDate, $CurrentTime, "Sign-Out", "System Auto Sign-Out"] Global $sFilePath = @ScriptDir & "\temp.xls" Create_Form1() Func Create_Form1() $Form1 = GUICreate("XXX", 485, 531, -1, -1) GUISetBkColor(0xFFFFFF) $Form1_Graphic1 = GUICtrlCreateGraphic(0, 0, 490, 161) GUICtrlSetBkColor(-1, 0x9BBB58) $Form1_Label1 = GUICtrlCreateLabel("XXX", 40, 40, 218, 52) GUICtrlSetFont(-1, 27, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFFFBF0) GUICtrlSetBkColor(-1, 0x9BBB58) $Form1_Label2 = GUICtrlCreateLabel("XXX", 40, 72, 268, 52) GUICtrlSetFont(-1, 27, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFFFBF0) GUICtrlSetBkColor(-1, 0x9BBB58) $Form1_Label3 = GUICtrlCreateLabel("XXX", 98, 200, 289, 33) GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif") $Form1_Label4 = GUICtrlCreateLabel("XXX", 64, 296, 151, 20) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $Form1_Label5 = GUICtrlCreateLabel("XXX", 64, 320, 154, 20) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $Form1_Label6 = GUICtrlCreateLabel("XXX", 64, 416, 160, 20) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $Form1_Label7 = GUICtrlCreateLabel("XXX", 64, 440, 106, 20) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $Form1_Button1 = GUICtrlCreateButton("Button1", 236, 292, 201, 45, $BS_BITMAP) $Form1_Button2 = GUICtrlCreateButton("Button2", 236, 416, 201, 45, $BS_BITMAP) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE $Form1_Result1 = MsgBox(52,"", "Are you sure you want to exit?") If $Form1_Result1 = 6 Then Exit Case $msg = $Form1_Button1 GUIDelete($Form1) Create_Form2() ExitLoop Case $msg = $Form1_Button2 GUIDelete($Form1) If ProcessExists("excel.exe") Then ProcessClose("excel.exe") Global $oExcel = _ExcelBookOpen($sFilePath,0) ExcelFindLastRow() Global $ConcatVal = "Sign-In" Global $aFound = _ExcelFindInRange($oExcel, $ConcatVal, "L1:L"&$iLastRow) ;Found the total number of row with $ConcatVal keyword Global $TotalSignIn = $aFound[0][0] $i = 1 While $i <= $TotalSignIn Global $SelectedRow = $aFound[$i][3] Global $AutoSignOutDateDiffData = _ExcelReadArray($oExcel, $SelectedRow, 1, 13, 0);The individual column data respective to $TotalSignIn $ConvertYear = StringMid ($AutoSignOutDateDiffData[7], 1, 4) $ConvertMonth = StringMid ($AutoSignOutDateDiffData[7], 5, 2) $ConvertDate = StringMid ($AutoSignOutDateDiffData[7], 7, 2) $CombineDate = $ConvertYear&"/"&$ConvertMonth&"/"&$ConvertDate $AutoSignOutDateDiff = _DateDiff("D", $CombineDate, _NowCalcDate()) If $AutoSignOutDateDiff >= 1 Then _ExcelWriteArray($oExcel, ($aFound[$i][3]), 10, $ExcelSignOutArrayWRemark, 0) EndIf $i = $i + 1 WEnd _ExcelBookClose($oExcel,1) Create_Form3() ExitLoop EndSelect WEnd EndFunc Func Create_Form3() $Form3 = GUICreate("X", 485, 531, -1, -1) GUISetBkColor(0xFFFFFF) $Form3_Graphic1 = GUICtrlCreateGraphic(0, 0, 490, 161) GUICtrlSetBkColor(-1, 0x9BBB58) $Form3_Label1 = GUICtrlCreateLabel("X", 40, 40, 218, 52) GUICtrlSetFont(-1, 27, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFFFBF0) GUICtrlSetBkColor(-1, 0x9BBB58) $Form3_Label2 = GUICtrlCreateLabel("X", 40, 72, 268, 52) GUICtrlSetFont(-1, 27, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFFFBF0) GUICtrlSetBkColor(-1, 0x9BBB58) Global $Form3_ListView1 = GUICtrlCreateListView("1|2|3|4|5", 0, 161, 485, 250, BitOR($GUI_SS_DEFAULT_LISTVIEW,$LVS_SINGLESEL,$LVS_NOSORTHEADER), $LVS_EX_FULLROWSELECT) GUICtrlSetFont(-1, 9, 800, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, $GUI_BKCOLOR_LV_ALTERNATE) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 35) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 130) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 90) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 130) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 4, 100) $Form3_Button4 = GUICtrlCreateButton("Button4", 145, 420, 201, 45, $BS_BITMAP) $Form3_Button3 = GUICtrlCreateButton("Button3", 8, 496, 73, 30, $BS_BITMAP) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE $Form3__Result1 = MsgBox(52,"", "Are you sure you want to exit?") If $Form3__Result1 = 6 Then Exit Case $Form3_Button4 GUIDelete($Form3) Create_Form1() ExitLoop Case $Form3_Button3 GUIDelete($Form3) Create_Form1() ExitLoop EndSwitch WEnd EndFunc Func ExcelFindLastRow() $oExcel1 = ObjGet($sFilePath, "Excel.Application") $oSheet = $oExcel1.ActiveSheet Global $iLastRow = $oSheet.Cells.Find('*', $oSheet.Cells(1, 1), Default, Default, 1, 2).Row EndFunc Func _ExcelFindInRange($oExcel, $sFindWhat, $sRangeOrRowStart, $iColStart = 1, $iRowEnd = 1, $iColEnd = 1, $iDataType = 0, $iWholeOrPart = 2, $fMatchCase = False, $fMatchFormat = "") Local $iCount, $sA1, $sR1C1, $sFound, $Temp1, $Temp2, $sFirst If NOT IsObj($oExcel) Then Return SetError(1, 0, 0) If $iDataType <> 0 Then If $iDataType <> -4163 Or $iDataType <> -4123 Or $iDataType <> -4144 Then Return SetError(4, 0, 0) EndIf EndIf If $iWholeOrPart < 1 Or $iWholeOrPart > 2 Then Return SetError(5, 0, 0) If NOT StringRegExp($sRangeOrRowStart, "[A-Z,a-z]", 0) Then If $sRangeOrRowStart < 1 Then Return SetError(2, 0, 0) If $iColStart < 1 Then Return SetError(2, 1, 0) If $iRowEnd < $sRangeOrRowStart Then Return SetError(3, 0, 0) If $iColEnd < $iColStart Then Return SetError(3, 1, 0) $oExcel.Range($oExcel.Cells($sRangeOrRowStart, $iColStart), $oExcel.Cells($iRowEnd, $iColEnd)).Select Else $oExcel.Range($sRangeOrRowStart).Select EndIf If $iDataType = 0 Then If $fMatchFormat = "" Then $oFound = $oExcel.Selection.Find($sFindWhat, $oExcel.ActiveCell, Default, $iWholeOrPart, Default, Default, $fMatchCase, Default) Else $oFound = $oExcel.Selection.Find($sFindWhat, $oExcel.ActiveCell, Default, $iWholeOrPart, Default, Default, $fMatchCase, Default, $fMatchFormat) EndIf Else If $fMatchFormat = "" Then $oFound = $oExcel.Selection.Find($sFindWhat, $oExcel.ActiveCell, $iDataType, $iWholeOrPart, Default, Default, $fMatchCase, Default) Else $oFound = $oExcel.Selection.Find($sFindWhat, $oExcel.ActiveCell, $iDataType, $iWholeOrPart, Default, Default, $fMatchCase, Default, $fMatchFormat) EndIf EndIf If IsObj($oFound) Then $oFound.Activate Else Local $aFound[1][1] $aFound[0][0] = 0 Return $aFound EndIf While 1 If $iCount > 0 And $iCount < 2 Then $sFirst = $sA1 $Temp1 = $oExcel.ActiveCell.Address $Temp2 = $oExcel.ActiveCell.Address(True, True, $xlR1C1) If $Temp1 = $sFirst Then ExitLoop If $iCount > 0 Then $sA1 = $sA1 & "*" & $Temp1 $sR1C1 = $sR1C1 & "*" & $Temp2 Else $sA1 = $Temp1 $sR1C1 = $Temp2 EndIf $iCount += 1 $oExcel.Selection.FindNext($oExcel.ActiveCell).Activate WEnd Local $aFound[$iCount + 1][4] $sA1 = StringReplace($sA1, "$", "") Local $aA1 = StringSplit($sA1, "*") Local $aR1C1 = StringSplit($sR1C1, "*") $aFound[0][0] = $iCount For $xx = 1 To $iCount $aFound[$xx][0] = $aA1[$xx] $aFound[$xx][1] = $aR1C1[$xx] $Temp1 = StringRegExp($aR1C1[$xx], "[RZ]([^CS]*)[CS](.*)",3) $aFound[$xx][2] = Number($Temp1[1]) $aFound[$xx][3] = Number($Temp1[0]) Next Return $aFound _ExcelBookClose($oExcel, 1, 0) EndFunc Something like this should kill excel.exe when you hit "Button 2". You'll have to elaborate on the temp.xls however. -Cheers I think this line If ProcessExists("excel.exe") Then ProcessClose("excel.exe") needs to be at the bottom before OP is exiting out of the loop, if OP is going to go that route, 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator
lolipop Posted March 14, 2013 Author Posted March 14, 2013 (edited) I might have found it - you open an object for excel in your code? with this function ExcelFindLastRow()edit - easy enough to test on your end - just comment out the call to that function and see if it resolves?edit - sorry, and just hard code last row?Yes, I did open an object with function ExcelFindLastRow(). It was from some example I found in the forum and I modify it for use. This there a way to close that object properly? I have tried to include the _ExcelBookClose into the function ExcelFindLastRow(), but it doesn't seems to work.The number of row for the excel spreadsheet is not the same everytime I open it(By design) has I can't hardcode the last row. I need some ways to always calculate the last row before I can proceed with the rest of the program. Perhaps you have other advise for me?Basically I'm writing a basic login system with the excel spreadsheet as the database containing users particulars. Therefore the entry in the excel spreadsheet is always changing.Btw the excel version is Excel 2010 Edited March 14, 2013 by lolipop
lolipop Posted March 14, 2013 Author Posted March 14, 2013 Something like this should kill excel.exe when you hit "Button 2". You'll have to elaborate on the temp.xls however.-CheersThanks 4gotn1 but I really don't wish to go thru the ProcessClose command way becos when I close it this way excel doesn't seems to close properly. When I open the excel spreadsheet manually, excel will always prompt me that the previous session didn't close properly and asking me if I wanted to do document recovery for it.
nitekram Posted March 14, 2013 Posted March 14, 2013 (edited) Look in the help file for _ExcelReadSheetToArray(), you should be able to use this? EDIT removed code, as I would have to have excel sheet to test, plus have excel installed Edited March 14, 2013 by nitekram 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator
lolipop Posted March 15, 2013 Author Posted March 15, 2013 After searching thru the forum countless time. Finally manage to solve the problem. It seems to be a bug of Excel 2010. More info @ The fix is simply. Just add $oExcel = 0 after _ExcelBookClose and Excel should release the obj the close. Weird that the bug still exist cos Water seems to mention that it was fix in one of the beta some time back. Thanks nitekram for the help.
nitekram Posted March 15, 2013 Posted March 15, 2013 Watch for an updated version of his UDF, as @water is in the process of creating an Alpha version of it. AND it is much faster reading the files. 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator
water Posted March 15, 2013 Posted March 15, 2013 After searching thru the forum countless time. Finally manage to solve the problem. It seems to be a bug of Excel 2010. More info @ The fix is simply. Just add $oExcel = 0 after _ExcelBookClose and Excel should release the obj the close. Weird that the bug still exist cos Water seems to mention that it was fix in one of the beta some time back. The problem I had was caused by me. If you run a 64 bit OS and the 32 bit version of Office you have to compile your AutoIt scripts fro 32 bit.So it's not a bug in AutoIt but a user problem. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
water Posted March 15, 2013 Posted March 15, 2013 Watch for an updated version of his UDF, as @water is in the process of creating an Alpha version of it. AND it is much faster reading the files.I hope to release a new alpha quite soon. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
lolipop Posted March 16, 2013 Author Posted March 16, 2013 The problem I had was caused by me. If you run a 64 bit OS and the 32 bit version of Office you have to compile your AutoIt scripts fro 32 bit.So it's not a bug in AutoIt but a user problem.Don't worry water, I'm not saying it's autoit bug. I think I read somewhere that it's due to Excel not releasing the obj properly. Fyi, I'm using office 2010, running 32bit windows 7 and compiling in 32bit but I still face the same problem.Can't wait for the new release of Excel UDF. Nice job.
water Posted March 16, 2013 Posted March 16, 2013 Not closing the Excel application is caused by this line in your code:$oExcel = _ExcelBookOpen($sFilePath,0)After the function call $oExcel contains a reference to the Excel application. As long as this reference "points" to Excel the application is still running. So you need to reset all global variables ($oExcel, ) to 0 to end Excel. In the new UDF function _Excel_Close does this automatically. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now