PC Review


Reply
Thread Tools Rate Thread

Copy Selected Text from Text Box

 
 
Gmspences10@googlemail.com
Guest
Posts: n/a
 
      28th Feb 2007
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

 
Reply With Quote
 
 
 
 
NickHK
Guest
Posts: n/a
 
      28th Feb 2007
Look at the .SelText property of the text box.

NickHK

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
Gmspences10@googlemail.com
Guest
Posts: n/a
 
      28th Feb 2007
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
>
> <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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
> >


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
find text and copy selected rows from text and loop bluewatermist Microsoft Excel Programming 4 17th Nov 2009 08:20 AM
Copy selected text from an external application macrow Microsoft VB .NET 1 20th Nov 2007 07:00 AM
Can't Copy Column of Selected Text =?Utf-8?B?SkRGWEQ=?= Microsoft Word Document Management 1 27th Apr 2006 09:35 PM
Outlook 2003 Copy Selected Text Macro webstuck Microsoft Outlook Discussion 4 2nd Nov 2005 09:18 AM
cannot copy selected text Robin Microsoft Word Document Management 4 30th Jan 2004 03:35 AM


Features
 

Advertising
 

Newsgroups
 


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