Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default Copy text box contents

I would like to have my program copy the contents of a text box on a
form to the clipboard as soon as it is filled and exited. The result
would be the same as if I went back and double-clicked on the text box
and pressed Ctrl+C so it can be pasted into another program.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Copy text box contents

I put a text box on a form. Loaded the TextBox1 using the form initialize
event. Then set focus to select the current value of the text, and then
copied the TextBox.
It put the text on the clip board and I could then pick a cell to paste the
text to. Here is the code behind the Userform.

Private Sub UserForm_Click()
TextBox1.SetFocus
TextBox1.Copy
Unload UserForm1
End Sub

Private Sub UserForm_Initialize()
Me.TextBox1.Text = Range("B3").Value
End Sub


"John Pierce" wrote:

I would like to have my program copy the contents of a text box on a
form to the clipboard as soon as it is filled and exited. The result
would be the same as if I went back and double-clicked on the text box
and pressed Ctrl+C so it can be pasted into another program.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default Copy text box contents

On Aug 12, 9:10*pm, JLGWhiz wrote:
I put a text box on a form. *Loaded the TextBox1 using the form initialize
event. *Then set focus to select the current value of the text, and then
copied the TextBox.
It put the text on the clip board and I could then pick a cell to paste the
text to. *Here is the code behind the Userform.

Private Sub UserForm_Click()
* * TextBox1.SetFocus
* * TextBox1.Copy
* * Unload UserForm1
End Sub

Private Sub UserForm_Initialize()
* * Me.TextBox1.Text = Range("B3").Value
End Sub

This isn't working for me. I believe the true test of what I'm trying
to do would be to create a form
with two text boxes. Type something in the first text box then press
tab to go to the next text box,
press Crtl+V and paste what was just typed in the first box. Of
course, I don't know if it can be done,
but it seems that an Exit or Afterupdate event might do it.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copy text box contents

Try it this way...

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
With TextBox1
.SelStart = 0
.SelLength = Len(.Text)
.Copy
End With
End Sub

Whenever focus moves from TextBox1 to any other control OR if the UserForm
is closed (thus effectively exiting the TextBox), the contents of TextBox1
will be placed in the Clipboard... erasing anything that is already in the
Clipboard, of course. This makes it a "dangerous" functionality to
implement; for example, what if your user copied something into the
Clipboard from a parallel running program, closed that program, came back to
your program and exited that TextBox, closed or left your program and went
to paste what he/she thought was in the Clipboard?

Rick


"John Pierce" wrote in message
...
On Aug 12, 9:10 pm, JLGWhiz wrote:
I put a text box on a form. Loaded the TextBox1 using the form initialize
event. Then set focus to select the current value of the text, and then
copied the TextBox.
It put the text on the clip board and I could then pick a cell to paste
the
text to. Here is the code behind the Userform.

Private Sub UserForm_Click()
TextBox1.SetFocus
TextBox1.Copy
Unload UserForm1
End Sub

Private Sub UserForm_Initialize()
Me.TextBox1.Text = Range("B3").Value
End Sub

This isn't working for me. I believe the true test of what I'm trying
to do would be to create a form
with two text boxes. Type something in the first text box then press
tab to go to the next text box,
press Crtl+V and paste what was just typed in the first box. Of
course, I don't know if it can be done,
but it seems that an Exit or Afterupdate event might do it.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA - Insert row, copy contents of original row except for contents of columns A-N Royzer Excel Programming 4 February 21st 12 08:04 PM
VBA - Insert row, copy contents of original row except for contents of column A Royzer Excel Programming 4 February 21st 12 02:47 PM
Copy cell contents, then paste into the same cell with other text. bluenote31 Excel Discussion (Misc queries) 4 February 9th 10 09:18 PM
Can I copy cell contents to an autoshape as text using a macro? Syndrome Excel Programming 1 July 11th 06 01:16 PM
How do I copy the contents of a range of text cells and paste into one cell? davfin Excel Discussion (Misc queries) 7 July 4th 06 08:16 AM


All times are GMT +1. The time now is 01:57 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"