VBA TIPS
Getting text from the clipboard

With DataObject object, you can get text strings from the cripboard. Looping each element of ClipboardFormats and it returns xlClipboardFormatText(=0), it means text has been copied into the clipboard.

This property returns an array of numeric values. To determine whether a particular format is on the Clipboard compare each element of the array with one of the following XlClipboardFormat constants:
  • xlClipboardFormatBIFF
  • xlClipboardFormatBIFF2
  • xlClipboardFormatBIFF3
  • xlClipboardFormatBIFF4
  • xlClipboardFormatBinary
  • xlClipboardFormatBitmap
  • xlClipboardFormatCGM
  • xlClipboardFormatCSV
  • xlClipboardFormatDIF
  • xlClipboardFormatDspText
  • xlClipboardFormatEmbeddedObject
  • xlClipboardFormatEmbedSource
  • xlClipboardFormatLink
  • xlClipboardFormatLinkSource
  • xlClipboardFormatLinkSourceDesc
  • xlClipboardFormatMovie
  • xlClipboardFormatNative
  • xlClipboardFormatObjectDesc
  • xlClipboardFormatObjectLink
  • xlClipboardFormatOwnerLink
  • xlClipboardFormatPICT
  • xlClipboardFormatPrintPICT
  • xlClipboardFormatRTF
  • xlClipboardFormatScreenPICT
  • xlClipboardFormatStandardFont
  • xlClipboardFormatStandardScale
  • xlClipboardFormatSYLK
  • xlClipboardFormatTable
  • xlClipboardFormatText
  • xlClipboardFormatToolFace
  • xlClipboardFormatToolFacePICT
  • xlClipboardFormatVALU
  • xlClipboardFormatWK1


Option Explicit

Sub GettextFromClipboard()
    Dim objCB As DataObject
    Dim intCnt As Integer
    Set objCB = New DataObject
    objCB.GetFromClipboard
    For intCnt = 1 To UBound(Application.ClipboardFormats)
        If Application.ClipboardFormats(intCnt) = xlClipboardFormatText Then
            Debug.Print objCB.GetText(intCnt)
        End If
     Next
     Set objCB = Nothing
End Sub




| HOME |
Copyright © cellmasters.net - colo's junk room All Right Reserved
ABOUT
WORKS
THE CELL MASTERS
CONTACT
LINKS
Tips and Information about Microsoft Excel|Masaru Kaji aka Colo