Av8tordude
Well-known Member
- Joined
- Oct 13, 2007
- Messages
- 1,075
- Office Version
- 2019
- Platform
- Windows
I have a userform that will allow me to paste into a multi-line textbox with what I have copied to the clipboard. It works well, but can someone assist me with editing the code to allow me to append more copied text under the last copied text seperating each new paste with a space.
i.e.
Paste text 1
Paste text 2
Paste text 3
i.e.
Paste text 1
Paste text 2
Paste text 3
Code:
Private Sub CommandButton3_Click()
'Paste text from clipboard
'the following code must have a reference added for
'"Microsoft Forms 2.0 Object Library" in the project references.
On Error GoTo My_Err
Dim DataObj As New MSForms.DataObject
DataObj.GetFromClipboard
TextBox1.Text = DataObj.GetText
MsgBox "Pasted"
Exit Sub
My_Err:
MsgBox "An Error occured when you tried to use the Clipboard. Make sure you have added a reference to MS Forms 2.0 Object Library: " & Err.Number & ":" & Err.Description
End Sub