Excel VBA Clipboard issue
In my kmz file folder structure, I have 7 png files that relate to folders and overlays common to every project.
I want to take the 7 png files used in the kmz file and embed them into an excel sheet and copy them into the kmz file structure when the routine is run to create the kmz file rather than copy them from some arbitrary folder on my c drive.
If I where to do it manually I would right click the shape/image and copy it to the clipboard. Open an image software and paste it and save it in my file structure. But obviously I don’t want to do it manually. I want to do it programmatically and keep my transparency. My vba code has two ways to copy the shape.
Option 1 is to use the Copy method
Option 2 is to use the CopyPicture method
Sheets("External Data").Shapes("Pole_Mark").CopyPicture xlScreen, xlPicture
If I run my code and stop after that copy line either 1 or 2 and open an image editor and paste the clipboard
Option 1 does not maintain the transparency but looks normal
Option 2 does what I want it to do: Looks normal and maintains transparency.
If I run my code and paste the clipboard using imagemagick VBA command
C = objIMG.Convert("clipboard:", "-background", "transparent", "-gravity", "center", stKMLFiles & "\Pole_Mark" & ".png")
Option 1 runs the code but does not maintain the transparency and causes a pixel shift where 3 or 4 columns of pixels on the right are shifted to the left.
Option 2 gives me a run-time error. '-2147215503 (80041771)': Automation error.
At this point I’m pretty sure option 2 is the method I need to use to copy my image. I just need a way to save it now.
Any ideas? I think Imagemagick should work. I'm just too new to it to know if I'm doing something wrong or not.
I did find this though - https://stackoverflow.com/questions/260 ... t-in-excel