Bilder aus Excel die in der Zwischenablage sind einfügen

  • Excel

Es gibt 1 Antwort in diesem Thema. Der letzte Beitrag () ist von sviper.

    Bilder aus Excel die in der Zwischenablage sind einfügen

    Hi ich habe ein Problem wenn ich Bilder aus Excel in die Zwischenablage lege und die per

    Dim image as system.drawing.image

    image = clipboard.getimage()

    picture1.image = image

    einfügen will, um sie dann in meine picturebox (picture1) zu legen geht das mit Excel 2007 jedoch nicht mit Excel 2003!!

    Ich habe herausgefunden das Excel 2003 die datei in png speichert und ich die in der Zwischenablage suchen muss oder so!

    Die Lösung habe ich gefunden! Bin nur nicht in der Lage das in VB umzuschreiben!

    Bin halt noch neu in VB!

    I've found the solution.

    Apparently Excel 2007 does not copy the image to the clipboard in the same file format. I iterated through Clipboard.GetDataObject().GetFormats() and found that it contained the following:

    Office Drawing Shape Format MetaFilePict EnhancedMetafile PNG+Office Art JFIF+Office Art GIF+Office Art PNG JFIF GIF ActiveClipboard

    Quellcode

    1. if (Clipboard.GetImage() != null) //Excel 2007
    2. {
    3. pictureBox1.Width = Clipboard.GetImage().Width;
    4. pictureBox1.Height = Clipboard.GetImage().Height;
    5. pictureBox1.Image = Clipboard.GetImage();
    6. //...
    7. }
    8. else if(Clipboard.GetDataObject().GetDataPresent("PNG")) //Excel 2003
    9. {
    10. Clipboard.GetDataObject().GetFormats()
    11. IDataObject data = Clipboard.GetDataObject();
    12. MemoryStream ms = (MemoryStream)data.GetData("PNG");
    13. pictureBox1.Width = Image.FromStream(ms).Width;
    14. pictureBox1.Height = Image.FromStream(ms).Height;
    15. pictureBox1.Image = Image.FromStream(ms);
    16. //...
    17. }
    Habe es geschafft!

    es müssen folgende Zeile im Programm stehen:

    Quellcode

    1. Bild befindet sich in Zwischenablage!!!
    2. dim data
    3. dim imagepng
    4. Clipboard.GetDataObject().GetFormats()
    5. data = Clipboard.GetDataObject()
    6. imagepng = data.getdata("png")
    7. image = image.FromStream(imagepng) 'gesuchtes png Bild aus Zw.


    :thumbsup: :thumbsup: :thumbsup: