Ratslinger has provided code to perform actions on a string in a text control and to determine the position of the cursor following these actions. The essential was as follows (where ‘temp’ was the modified string):
Rem Save position of entry
iSelMin = oEvent.Source.getSelection().Min
iSelMax = oEvent.Source.getSelection().Max
Rem Load modified text back out
oEvent.Source.setText(temp)
Rem Need to set cursor at last position of data entered
oSelection.Min = iSelMin
oSelection.Max = iSelMax
oEvent.Source.Selection = oSelection
I have to admit that I have not fully understood what is going on here, and I have not succeeded in using it in other contexts. (I have not found documentation on the ‘Selection’ property.) What I want to do now, having used a macro (intercepting a keystroke) to add to the text in a control, is simply to move the cursor (within the same control/field) to the end of the text. Advice please!