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
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
- if (Clipboard.GetImage() != null) //Excel 2007
- {
- pictureBox1.Width = Clipboard.GetImage().Width;
- pictureBox1.Height = Clipboard.GetImage().Height;
- pictureBox1.Image = Clipboard.GetImage();
- //...
- }
- else if(Clipboard.GetDataObject().GetDataPresent("PNG")) //Excel 2003
- {
- Clipboard.GetDataObject().GetFormats()
- IDataObject data = Clipboard.GetDataObject();
- MemoryStream ms = (MemoryStream)data.GetData("PNG");
- pictureBox1.Width = Image.FromStream(ms).Width;
- pictureBox1.Height = Image.FromStream(ms).Height;
- pictureBox1.Image = Image.FromStream(ms);
- //...
- }