Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
VBA - Insert row, copy contents of original row except for contents of columns A-N | Excel Programming | |||
VBA - Insert row, copy contents of original row except for contents of column A | Excel Programming | |||
Copy cell contents, then paste into the same cell with other text. | Excel Discussion (Misc queries) | |||
Can I copy cell contents to an autoshape as text using a macro? | Excel Programming | |||
How do I copy the contents of a range of text cells and paste into one cell? | Excel Discussion (Misc queries) |