GetFromClipboard Method

Applies To

DataObject object.

Description

Copies data from the Clipboard to a DataObject.

Syntax

String = object.GetFromClipboard( )

The GetFromClipboard method syntax has these parts:

Part

Description

object

Required. A valid object name.


Remarks

The DataObject can contain multiple data items, but each item must be in a different format. For example, the DataObject might include one text item and one item in a custom format; but cannot include two text items.

See Also

GetText method, PutInClipboard method.

Example

The following example demonstrates data movement from a TextBox to the Clipboard, from the Clipboard to a DataObject, and from a DataObject into another TextBox. The GetFromClipboard method transfers the data from the Clipboard to a DataObject. The Copy and GetText 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()
        'Need to select text before copying it to Clipboard
        TextBox1.SelStart = 0
        TextBox1.SelLength = TextBox1.TextLength
        TextBox1.Copy
    
        MyData.GetFromClipboard
        TextBox2.Text = MyData.GetText(1)
    End Sub
    
    Private Sub UserForm_Initialize()
        Set MyData = New DataObject
        TextBox1.Text = "Move this data to the Clipboard, to a DataObject," _
            & " then to TextBox2!"
    End Sub