Article ID: 183644
Article Last Modified on 6/17/2005
Sub GetClipBoardText()
Dim MyData As DataObject
Set MyData = New DataObject
Dim sClipText As String
On Error GoTo NotText
' Get data from the clipboard.
MyData.GetFromClipboard
' Assign clipboard contents to string variable.
sClipText = MyData.GetText(1)
MsgBox sClipText
NotText:
If Err <> 0 Then
MsgBox "Data on clipboard is not text."
End If
End Sub
For information about how to do this in earlier versions of Word, please
see the following article(s) in the Microsoft Knowledge Base:
82111 WordBasic Macro to Assign Clipboard Text to a String Variable
181058 OFF98: How to Run Sample Code from Knowledge Base Articles
163435 VBA: Programming Resources for Visual Basic for Applications
Additional query words: wordcon vb vba vbe
Keywords: kbhowto kbmacroexample KB183644