textbox.selection.copy

erik.van.geit

MrExcel MVP
Joined
Feb 1, 2003
Messages
17,832
Hi, folks,

Is there a simple function that can "see" which part of the text in a userform textbox is selected?

example
textbox 1 contains "text1 text2 text3"
the word in the middle is selected
then you click a button which executes my "fantasycode"
Me.Controls("Textbox1").SelectedPart.Copy (or copy to clipboard)

I see one major problem: clicking the button the Textbox isn't selected anymore :confused:

would the doubleclick-event be a solution ?
doubleclicking a word selects it
Private Sub txt_tb_DblClick(ByVal Cancel As MSForms.ReturnBoolean)SelectedWord.Copy ...
End Sub


I think there are some large codes on the internet who meet this problem. Needing so simple task, do we need so much lines of code? :(

A solution or some links would be greatly enjoyed :p
kind regards,
Erik
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

Scott Huish

MrExcel MVP
Joined
Mar 17, 2004
Messages
19,958
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
If you want to do it off a button:

Highlight the text in the textbox, and this example should show you what text was selected:

Code:
Private Sub CommandButton1_Click()
MsgBox TextBox1.SelText
End Sub
 

erik.van.geit

MrExcel MVP
Joined
Feb 1, 2003
Messages
17,832
Hotpepper,

That's really a simple solution :p
Just as needed.

Didn't know this syntax. Perhaps it's better to go: zzzzzzzzzzleepingggg.

Thank you!
Erik
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,167,815
Messages
5,855,791
Members
431,764
Latest member
scottishbigyin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top