@@ -31,22 +31,25 @@ IfMsgBox, OK
3131 }
3232 ; MsgBox, % IsObject(XL) ; Is excel an object?
3333 try {
34+ ; Make Excel invisible
35+ XL.Visible := 0
3436 ; Check if the workbook exists
3537 XL.Workbooks.Open(tgtFilePath)
3638 } catch {
39+ ; Make Excel invisible
40+ XL.Visible := 1
3741 ; Quit the application
38- if (XL.Workbooks.Count = 1 ){
39- XL.Quit
42+ if (XL.Workbooks.Count = 0 ){
43+ XL.Application.Quit()
44+ XL := ""
4045 }
46+
4147 ; Alert the user that the file was not found
4248 MsgBox , The necessary workbook was not found. Please create a hotstrings.xlsx file to continue.
4349 ExitApp
4450 Sleep , 2000
4551 }
4652
47- ; Make Excel Visible
48- XL.Visible := 1
49-
5053 ; select the sheet name containing the templates
5154 tgtSheet := XL.Worksheets(hotstringWorksheet)
5255
@@ -77,19 +80,19 @@ IfMsgBox, OK
7780
7881 }
7982 ; tell excel it's save so it wont harass you and close the document
80- XL.Application.ActiveWorkbook.saved := true
81- wbCount := XL.Workbooks.Count
82- if (XL.Workbooks.Count = 1 ){
83- XL.Quit
84- } else {
85- for WB in XL.Workbooks {
86- wbName := WB.Name
87- if (WB.Name = hotstringFilename){
88- WB.Close
89- }
90- }
83+ XL.Application.Workbooks(hotstringFilename).saved := true
84+ XL.Application.Workbooks(hotstringFilename).Close
85+
86+ tgtSheet := ""
87+ HotStringExtended := ""
88+ HotStringShortCut := ""
89+ XL := ""
90+
91+ if (XL.Workbooks.Count = 0 ){
92+ XL.Application.Quit()
9193 }
9294
95+
9396 :*:<now ::
9497 FormatTime , CurrentDateTime,, MM/ dd/ yyyy hh:mm:ss
9598 SendInput , %CurrentDateTime%
0 commit comments