ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy Selected Text from Text Box (https://www.excelbanter.com/excel-programming/384101-copy-selected-text-text-box.html)

[email protected]

Copy Selected Text from Text Box
 
Hello Friends,

Can anyone help with the following?

I am using a Control Toolbox text box on a worksheet so that users can
enter freetex ongoing, I need the users to be able to highlight a
range of the text to either copy to the clipboard or print it. At the
moment I can only copy all of the data contained in the text box with
the below code, can anyone add to this please?

Private Sub Label2_Click()
Dim MyData As DataObject
Set MyData = New DataObject
MyData.SetText TextBox1.Text
MyData.PutInClipboard
'wdapp.Selection.Copy
Set MyData = Nothing

'With Sheet10.TextBox1
' .SelStart = 0
' .SelLength = Len(TextBox1.Text)
' .Copy
' '.Shapes("TextBox1").Select Selection.Characters.Text
'End With
End Sub


NickHK

Copy Selected Text from Text Box
 
Look at the .SelText property of the text box.

NickHK

wrote in message
oups.com...
Hello Friends,

Can anyone help with the following?

I am using a Control Toolbox text box on a worksheet so that users can
enter freetex ongoing, I need the users to be able to highlight a
range of the text to either copy to the clipboard or print it. At the
moment I can only copy all of the data contained in the text box with
the below code, can anyone add to this please?

Private Sub Label2_Click()
Dim MyData As DataObject
Set MyData = New DataObject
MyData.SetText TextBox1.Text
MyData.PutInClipboard
'wdapp.Selection.Copy
Set MyData = Nothing

'With Sheet10.TextBox1
' .SelStart = 0
' .SelLength = Len(TextBox1.Text)
' .Copy
' '.Shapes("TextBox1").Select Selection.Characters.Text
'End With
End Sub




[email protected]

Copy Selected Text from Text Box
 
Fantastic,

its easy when you know how.

Dim MyData As DataObject
Set MyData = New DataObject
MyData.SetText TextBox1.SelText
MyData.PutInClipboard
'wdapp.Selection.Copy
Set MyData = Nothing

thank you very much Nick


NickHK wrote:
Look at the .SelText property of the text box.

NickHK

wrote in message
oups.com...
Hello Friends,

Can anyone help with the following?

I am using a Control Toolbox text box on a worksheet so that users can
enter freetex ongoing, I need the users to be able to highlight a
range of the text to either copy to the clipboard or print it. At the
moment I can only copy all of the data contained in the text box with
the below code, can anyone add to this please?

Private Sub Label2_Click()
Dim MyData As DataObject
Set MyData = New DataObject
MyData.SetText TextBox1.Text
MyData.PutInClipboard
'wdapp.Selection.Copy
Set MyData = Nothing

'With Sheet10.TextBox1
' .SelStart = 0
' .SelLength = Len(TextBox1.Text)
' .Copy
' '.Shapes("TextBox1").Select Selection.Characters.Text
'End With
End Sub




All times are GMT +1. The time now is 04:29 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com