![]() |
Find position of cursor in text box
Is there a way I can determine the position of the cursor in a text box in a
custom form? Reason - if the user has just typed a CR/LF I want the macro to add in a bullet point. I've made this happen when the cursor is at the end of the text by putting the following in an On Change macro if right(mytext,2) = chr(13) & chr(10) then mytext = mytext & chr(149) & chr(32) but I'm struggling for a method that works when the cursor is in the middle of the text. -- Adrian D.Bailey, Information and Systems Manager, Dept.Human Sciences Loughborough University, Loughborough Leics, LE11 3TU, UK. Tel: 01509 223007 Fax: 01509 223940 Community Warden, Storer and Burleigh Areas. Out-of-hours Tel: 01509 563263 -- |
Find position of cursor in text box
SelStart should do it if I understand you.
Private Sub TextBox1_Change() Debug.Print TextBox1.SelStart End Sub -- Jim "Adrian D. Bailey" wrote in message ... | Is there a way I can determine the position of the cursor in a text box in a | custom form? | | Reason - if the user has just typed a CR/LF I want the macro to add in a | bullet point. | I've made this happen when the cursor is at the end of the text by putting | the following in an On Change macro | if right(mytext,2) = chr(13) & chr(10) then mytext = mytext & chr(149) & | chr(32) | but I'm struggling for a method that works when the cursor is in the middle | of the text. | | -- | Adrian D.Bailey, Information and Systems Manager, Dept.Human Sciences | Loughborough University, Loughborough Leics, LE11 3TU, UK. | Tel: 01509 223007 Fax: 01509 223940 | | Community Warden, Storer and Burleigh Areas. Out-of-hours Tel: 01509 563263 | -- | | |
All times are GMT +1. The time now is 06:29 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com