Sub Sample()
Dim CB As Variant, i As Long
CB = Application.ClipboardFormats
If CB(1) = True Then
MsgBox "クリップボードは空です。", 48
Exit Sub
End If
For i = 1 To UBound(CB)
If CB(i) = xlClipboardFormatBitmap Then
ActiveSheet.Paste
Exit For
End If
Next i
End Sub
Sub Sample2()
Dim buf As String, buf2 As String, CB As New DataObject
buf = "tanaka"
With CB
.SetText buf ''変数のデータをDataObjectに格納する
.PutInClipboard ''DataObjectのデータをクリップボードに格納する
.GetFromClipboard ''クリップボードからDataObjectにデータを取得する
buf2 = .GetText ''DataObjectのデータを変数に取得する
End With
MsgBox buf2
End Sub