Private
Sub
TextBox1_KeyDown(
ByVal
KeyCode
As
MSForms.ReturnInteger,
ByVal
Shift
As
Integer
)
If
KeyCode = 13
And
Shift = 0
Then
If
replace_shortcut()
Then
KeyCode = 0
End
If
End
If
End
Sub
Function
replace_shortcut()
Static
Dic
As
Object
Dim
last_word
As
String
, last_word_index
As
Long
If
Dic
Is
Nothing
Then
Set
Dic = CreateObject(
"Scripting.Dictionary"
)
Dic.Add
"A123"
,
"Kunde anschreiben"
Dic.Add
"mfg"
,
"Mit freundlichen Grüßen"
Dic.Add
"lg"
,
"Liebe Grüße"
End
If
replace_shortcut =
False
With
TextBox1
last_word_index = Application.WorksheetFunction.Max( _
InStrRev(.Text,
" "
, -1, vbBinaryCompare), _
InStrRev(.Text, vbCr, -1, vbBinaryCompare), _
InStrRev(.Text, vbLf, -1, vbBinaryCompare), _
InStrRev(.Text, vbTab, -1, vbBinaryCompare), _
InStrRev(.Text,
"("
, -1, vbBinaryCompare)) + 1
last_word =
CStr
(Mid(.Text, last_word_index))
If
Dic.Exists(last_word)
Then
.Text = Mid(.Text, 1, Len(.Text) - Len(last_word)) & Dic(last_word)
replace_shortcut =
True
End
If
End
With
End
Function