Page 1 of 1

Possible bug w/ "clipboard:"

Posted: 2012-02-07T16:43:51-07:00
by odditude
I'm trying to use ImageMagick in conjunction with VBA to create PNGs from Excel via the clipboard. If the data is copied to the clipboard normally, ImageMagick works perfectly. However, if the data is copied to the clipboard through VBA, ImageMagick fails to see any image data on the clipboard.

The VBA code in question is:

Code: Select all

Range(<rangeObject>).CopyPicture xlScreen, xlPicture
which copies the contents of <rangeObject> to the clipboard as an image.

With this data, ImageMagick returns:

Code: Select all

C:\test>convert clipboard:myimage -density 150 -units pixelsperinch testpls.png
convert.exe: no bitmap on clipboard `myimage' @ error/clipboard.c/ReadCLIPBOARDImage/138.
convert.exe: missing an image filename `testpls.png' @ error/convert.c/ConvertImageCommand/3016.
With the same data,

Code: Select all

i_view32 /clippaste /convert=testIV.png
generates the image properly.

Installed version is ImageMagick-6.7.5-0-Q16-windows.zip (portable package) on Windows 7 (x64), running Excel 2010 (32-bit).

Easiest way to reproduce is by opening Excel, putting some random data in a cell, selecting said cell, and in the VBA Immediate window running:

Code: Select all

Selection.CopyPicture xlScreen, xlPicture
This will put the image data on the clipboard for analysis.

Re: Possible bug w/ "clipboard:"

Posted: 2012-02-13T09:12:30-07:00
by Werty
Are you sure you are feeding it image data and not just a Handle to the data ?

Try...

Code: Select all

Convert rose: clipboard:

then...

Convert clipboard: image.jpg
^this works for me, having no image data on the clipboard gives me the same error as yours, so it seems you arent getting the correct data on your clipboard.

Re: Possible bug w/ "clipboard:"

Posted: 2012-02-14T18:01:56-07:00
by odditude
OK - got it to work (you need to use xlBitmap instead of xlPicture). xlBitmap was giving me bad data in both programs before, likely due to Excel misbehaving.

Using InsideClipboard, though, I verified that xlPicture is passing just handles to a WMF and EMF; xlBitmap provides actual DIB and DIBv5 data.