Results 1 to 4 of 4

Thread: How Do You Save Whatever's In The Clipboard To An Object?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    219

    How Do You Save Whatever's In The Clipboard To An Object?

    Hi, I need to save the users clipboard contents to an object before I modify the clipboard, but I don't know how to do it. Any help is appreciated,

    Thanks

    Louix

  2. #2
    PowerPoster keystone_paul's Avatar
    Join Date
    Nov 2008
    Location
    UK
    Posts
    3,327

    Re: How Do You Save Whatever's In The Clipboard To An Object?

    Here's an example of getting text from the clipboard - to get other data types you just change the Data Format. If you delete the .Text after "DataFormats." intellisense will show you the different types.

    Code:
    Public Function GetClipboardText() As String
          Dim objClipboard As IDataObject = Clipboard.GetDataObject()
            With objClipboard
                If .GetDataPresent(DataFormats.Text) Then Return .GetData(DataFormats.Text)
            End With
        End Function

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    219

    Re: How Do You Save Whatever's In The Clipboard To An Object?

    Thank you

    this isn't quite what I was looking for, I said whatever's in the clipboard. Is there any way to get the format of the data in there then apply it to your code?

  4. #4
    PowerPoster keystone_paul's Avatar
    Join Date
    Nov 2008
    Location
    UK
    Posts
    3,327

    Re: How Do You Save Whatever's In The Clipboard To An Object?

    Well you can use the Clipboard.GetDataPresent function for each of the possible types in turn to see if there is an object of said type. (Bear in mind the clipboard could contain one of each possible format at any given time, ie just because it has some text doesn't mean it doesn't also have a TIFF or a File)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width