|
-
Nov 8th, 2004, 04:33 PM
#1
Thread Starter
Hyperactive Member
Copy/paste text box
I have an Excel app that uses VB forms. I was wondering if it is possible to be able to copy the contents of one text box and paste into another. I'm not sure how to go about this. Any help would be appreciated.
Thanks
-
Nov 9th, 2004, 04:17 AM
#2
Addicted Member
There is no real need for copy/paste. Use something like :-
TextBox2.Value = TextBox1.Value
Regards
BrianB
-------------------------------
-
Nov 9th, 2004, 12:53 PM
#3
Thread Starter
Hyperactive Member
I was looking for being able to highlight text, then right click and select copy, then click in a text box and right-click and select paste.
I don't see how that code is going to accomplish that.
-
Nov 10th, 2004, 03:39 AM
#4
it copies text1 INTO text2. isn't that what you wanted to do?
-
Nov 10th, 2004, 09:03 AM
#5
Thread Starter
Hyperactive Member
What event is going to tell the program that I want the text from text1 to go into text2?
-
Nov 11th, 2004, 10:02 AM
#6
Addicted Member
Any - it is up to you where you put the code - or put a button on the form. Or in some other code your run. etc etc
Regards
BrianB
-------------------------------
-
Nov 11th, 2004, 10:13 AM
#7
Thread Starter
Hyperactive Member
ok. Say I put two buttons on the form. One copy and one paste. When the button is clicked, what code returns the object name of the text box that has the selected text to copy in it? The form has approx. 30 to 40 text boxes on it.
-
Nov 11th, 2004, 10:25 AM
#8
ah, well that's a bit different than you had explained before (BrianB's answer works perfectly to copy from one known textbox to another).
I'm not sure if this is the right syntax for VBA, but it wont be far off:
VB Code:
'Copy:
Clipboard.Clear
Clipboard.SetText ActiveControl.Text
'or this to copy just the selected text:
'Clipboard.SetText ActiveControl.SelText
'Paste:
ActiveControl.Text = Clipboard.GetText
'or this to paste over the selected text:
'ActiveControl.Text = Left(ActiveControl.Text, ActiveControl.SelStart-1) + Clipboard.GetText + Mid(ActiveControl.Text, ActiveControl.SelStart+ActiveControl.SelLength)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|