Skip to content

Commit 74dc42b

Browse files
committed
Added variables and removed prefix
Added variables for filename and sheetname, updated text and cancel button on dialog box
1 parent 62f2d81 commit 74dc42b

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

XLSX Text Expander/XLSX Text Expander.ahk

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,23 @@
44
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
55
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
66
SetTitleMatchMode, 2
7-
; VERSION 110
8-
7+
; VERSION 112
98
; This text expander is a work in progress
109

10+
; name of file containing hotstrings
11+
hotstringFilename := "hotstrings.xlsx"
12+
; name of worksheet containing the hotstrings
13+
hotstringWorksheet := "Templates"
14+
1115
; initialize the XL variable
1216
XL :=
1317

1418
; fetch the correct file path
15-
tgtFilePath := A_ScriptDir "\hotstrings.xlsx"
19+
tgtFilePath := A_ScriptDir "\" hotstringFilename
1620

17-
18-
MsgBox, 1, AutoHotkey Text Expander, This text expander app allows you to automatically convert short phrases into long blocks of text.`n`nFor example, typing <now will automatically expand into the current date and time. All shortcuts used in this app are prefixed with the < symbol.`n`nNew shortcuts can be added in the hotstrings.xlsx file included with this app.
21+
MsgBox, 1, AutoHotkey Text Expander, This text expander allows you to automatically convert short phrases into long blocks of text. New shortcuts can be added in the included hotstrings.xlsx file.`n`nExample, typing <ate will expand into "AutoHotkey Text Expander"`n`nBuilt In Hotstring:`n<now = DateTime(MM/dd/yyyy hh:mm:ss)
1922
IfMsgBox, Cancel
20-
Return
23+
ExitApp
2124
IfMsgBox, OK
2225
try {
2326
; Check if excel is active
@@ -45,7 +48,10 @@ IfMsgBox, OK
4548
XL.Visible := 1
4649

4750
; select the sheet name containing the templates
48-
tgtSheet := XL.Worksheets("Templates")
51+
tgtSheet := XL.Worksheets(hotstringWorksheet)
52+
53+
; activate the sheet with hotstrings
54+
tgtSheet.Activate
4955

5056
; Sort the data by column C so it can loop over all of the hotstrings without empty cells
5157
tgtSheet.UsedRange.Offset(1).Sort(XL.Columns(3), 1)
@@ -66,7 +72,7 @@ IfMsgBox, OK
6672
HotStringExtended := StrReplace(StrReplace(StrReplace(HotStringExtended, "!","{!}"),"`r","{enter}"),A_Space A_Space,"{space 2}")
6773

6874
; assign both variables to a hotkey
69-
hotstring(":*:" "<" HotStringShortCut, HotStringExtended)
75+
hotstring(":*:" HotStringShortCut, HotStringExtended)
7076
; MsgBox, 4, , %HotStringShortCut% - %HotStringExtended%`n`nContinue?
7177

7278
}
@@ -78,7 +84,7 @@ IfMsgBox, OK
7884
} else {
7985
for WB in XL.Workbooks {
8086
wbName := WB.Name
81-
if(WB.Name = "hotstrings.xlsx"){
87+
if(WB.Name = hotstringFilename){
8288
WB.Close
8389
}
8490
}

XLSX Text Expander/hotstrings.xlsx

45 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)