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
Printable View
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
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
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?
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)