Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default Insert Text to the cursor position of a Text box from another cont

Hi,

I have a string of text in a text box and I want to allow the user to select
values from a list box beside the text box and dependent on where the cursor
was last positioned in the text box before the selection of the item in the
list box....I want to insert the value selected from the list box...

Can someone suggest an approached ?

I have found something along the lines of what i need but only for Access
VBA...it does not seem to work with the same properties in Excel VBA
http://www.everythingaccess.com/tuto...ursor-position

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Insert Text to the cursor position of a Text box from another cont

You are going to kick yourself when you find out how easy what you asked is
to do. First off, though, I would suggest you insert the text into the
TextBox in response to a double click in the ListBox rather than a single
click; that way the user won't be able to accidentally click in the ListBox
and add text to the TextBox unknowingly. Assuming you agree, here is the
ListBox's DblClick event code that will do what you asked (if you disagree,
just put the code into the ListBox's Click event instead)...

Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
TextBox1.SelText = ListBox1.Text
End Sub

That is it; see... I told you that you would want to kick yourself over how
easy this is to do.<g By the way, obviously change the example control
names I used to match the actual names you have given them. Also, for the
user's convenience, set the TextBox's HideSelection property to False so
he/she can see where the text will end up going.

By the way, since you didn't say, I had to guess... I set this up with the
controls on a UserForm, but it should be modifiable for use with ActiveX
controls (from the Controls Toolbar) placed directly on the worksheet.

Rick


"scott56hannah" wrote in message
...
Hi,

I have a string of text in a text box and I want to allow the user to
select
values from a list box beside the text box and dependent on where the
cursor
was last positioned in the text box before the selection of the item in
the
list box....I want to insert the value selected from the list box...

Can someone suggest an approached ?

I have found something along the lines of what i need but only for Access
VBA...it does not seem to work with the same properties in Excel VBA
http://www.everythingaccess.com/tuto...ursor-position


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default Insert Text to the cursor position of a Text box from another

Rick,

Thanks for that....it worked well...and maybe I should kick myself

Scott

"Rick Rothstein (MVP - VB)" wrote:

You are going to kick yourself when you find out how easy what you asked is
to do. First off, though, I would suggest you insert the text into the
TextBox in response to a double click in the ListBox rather than a single
click; that way the user won't be able to accidentally click in the ListBox
and add text to the TextBox unknowingly. Assuming you agree, here is the
ListBox's DblClick event code that will do what you asked (if you disagree,
just put the code into the ListBox's Click event instead)...

Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
TextBox1.SelText = ListBox1.Text
End Sub

That is it; see... I told you that you would want to kick yourself over how
easy this is to do.<g By the way, obviously change the example control
names I used to match the actual names you have given them. Also, for the
user's convenience, set the TextBox's HideSelection property to False so
he/she can see where the text will end up going.

By the way, since you didn't say, I had to guess... I set this up with the
controls on a UserForm, but it should be modifiable for use with ActiveX
controls (from the Controls Toolbar) placed directly on the worksheet.

Rick


"scott56hannah" wrote in message
...
Hi,

I have a string of text in a text box and I want to allow the user to
select
values from a list box beside the text box and dependent on where the
cursor
was last positioned in the text box before the selection of the item in
the
list box....I want to insert the value selected from the list box...

Can someone suggest an approached ?

I have found something along the lines of what i need but only for Access
VBA...it does not seem to work with the same properties in Excel VBA
http://www.everythingaccess.com/tuto...ursor-position



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find position of cursor in text box Adrian D. Bailey Excel Programming 2 April 2nd 07 05:16 PM
Insert copied row at cursor position BEEJAY Excel Programming 3 February 16th 07 09:44 PM
Automating Data Entry (Position the cursor, insert row) Bethany Excel Programming 4 November 28th 06 06:54 PM
Retrieving text being typed and cursor position using VBA or automation, how? Kallepalle Excel Programming 2 May 23rd 04 12:40 PM
How do I get cursor position and text being typed? Kallepalle Excel Programming 2 February 19th 04 05:49 PM


All times are GMT +1. The time now is 09:05 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"