GetFormat Method Example

This example uses the GetFormat method to determine the format of the data on the Clipboard object. To try this example, paste the code into the Declarations section of a form, and then press F5 and click the form.

Private Sub Form_Click ()
   ' Define bitmap formats.
   Dim ClpFmt, Msg   ' Declare variables.
   On Error Resume Next   ' Set up error handling.
   If Clipboard.GetFormat(vbCFText) Then ClpFmt = ClpFmt + 1
   If Clipboard.GetFormat(vbCFBitmap) Then ClpFmt = ClpFmt + 2
   If Clipboard.GetFormat(vbCFDIB) Then ClpFmt = ClpFmt + 4
   If Clipboard.GetFormat(vbCFRTF) Then ClpFmt = ClpFmt + 8
   Select Case ClpFmt
      Case 1
         Msg = "The Clipboard contains only text."
      Case 2, 4, 6
         Msg = "The Clipboard contains only a bitmap."
      Case 3, 5, 7
         Msg = "The Clipboard contains text and a bitmap."
      Case 8, 9
         Msg = "The Clipboard contains only rich text."
      Case Else
         Msg = "There is nothing on the Clipboard."
   End Select
   MsgBox Msg   ' Display message.
End Sub