locked
Embedded Objects/Saving From Clipboard RRS feed

  • Question

  • I'm able to copy an embedded object, specifically in Word, to the clipboard. I can even see the various types of data stored in the clipboard. My problem is getting to the object or package contents.

    I want to mimick the following:

    1. Select an object by clicking once on it.
    2. Copy to clipboard
    3. Paste to folder location.

    I've got it through #2, but #3 has got me stumped.  I don't have all the code I've tried, but I could put the latest on here if necessary.

    Using VB.NET if that helps.

    Thanks for the help.

    Tuesday, October 17, 2006 11:34 AM

All replies

  • in order for number 3 to work you will have to write out the file to disk....for the image format it is very easy and straight forward...

    Dim MyImage As Image = My.Computer.Clipboard.GetImage

    MyImage.Save("TheFilePath")

    For any other types you will have to manually read the data and then use the IO namespace to write the file to disk!

    Tuesday, October 17, 2006 3:00 PM
    Moderator
  • Tried that at first.

    This gives me "Object reference not set to an instance of an object"

    Any other ideas.

    Started looking at COleDataObject Class, but I can't find the equivalent in VB. *(&^*&^#)(*&

    Tuesday, October 17, 2006 6:24 PM
  • first of all for that code to work you need to make sure that the object type is an image...

    If My.Computer.Clipboard.ContainsImage Then

    Dim MyImage As Image = My.Computer.Clipboard.GetImage

    MyImage.Save("C:\MyBmp.Bmp")

    End If

    if it is not an image then you will have to code for each data type...strings would be easy enough to write with a streamtextwriter....other datatypes would have to be read and written as a binary type

    Tuesday, October 17, 2006 6:51 PM
    Moderator
  • Sometimes ...  I had mistakenly taken out the copy to clipboard. DDUUUUHHHHH

    So, it does have an image, but it's not what I'm looking for. I need a little push. If I have an enhancedmetafile type, how do I read that and write it?

    Tuesday, October 17, 2006 7:49 PM