How to copy file to Clipboard

syed

Member
This piece of code helped me to achieve what i want

Dim f() As String = {filePath}
Dim d As New DataObject(DataFormats.FileDrop, f)
System.Windows.Forms.Clipboard.SetDataObject(d, True)
 

sivagelli

Well-Known Member
This piece of code helped me to achieve what i want

Dim f() As String = {filePath}
Dim d As New DataObject(DataFormats.FileDrop, f)
System.Windows.Forms.Clipboard.SetDataObject(d, True)

This works perfectly with Notepad files.
MS Word or other files cannot be copied on to Clipboard just by passing the path.
 

sivagelli

Well-Known Member
My bad! Thanks for pointing out and please ignore my post.

When I tried on my machine, the code is copying a snapshot and of the file on to clipboard as an image. I tried with MS Word, MS Excel and PDFs.

Also, if you have more than 1 page, it is not copying all the pages on to clipboard, it captures just the first page.
 
Top