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

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,219,162
Messages
6,146,661
Members
450,706
Latest member
LGVBPP

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
Back
Top