PutInClipboard Method

Applies To

DataObject object.

Description

Moves data from a DataObject to the Clipboard.

Syntax

object.PutInClipboard

The PutInClipboard method syntax has these parts:

Part

Description

object

Required. A valid object.


Remarks

The PutInClipboard method replaces the contents of the Clipboard with the contents of the DataObject that is in Text format.

See Also

GetFromClipboard method, GetText method, SetText method.

Example

The following example demonstrates data movement from a TextBox to a DataObject, from a DataObject to the Clipboard, and from the Clipboard to another TextBox. The PutInClipboard method transfers the data from a DataObject to the Clipboard. The SetText and Paste methods are also used.

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains:

  • Two TextBox controls named TextBox1 and TextBox2.
  • A CommandButton named CommandButton1.
    Dim MyData As DataObject
    
    Private Sub CommandButton1_Click()
        Set MyData = New DataObject
        
        MyData.SetText TextBox1.Text
        MyData.PutInClipboard
    
        TextBox2.Paste
    End Sub
    
    Private Sub UserForm_Initialize()
        TextBox1.Text = "Move this data to a DataObject, to the Clipboard," _
    & " then to TextBox2!" End Sub