title: Copying an image - Excel VBA
body: <p>SYNOPSIS-</p>
  
  <p>I need to copy an image (.png format) embedded in one Excel picture object into another existing picture (overwriting its image data), while leaving intact the target shape's identity and fields (position, visibility, size, title, etc). This is with simple pictures, not ActiveX OLEObjects.</p>
  
  <hr>
  
  <p>SITUATION:</p>
  
  <p>I'm on Windows 7, Excel 2010.</p>
  
  <p>I've got a sheet with multiple picture objects in the UI.</p>
  
  <p>Depending on a user's setting, the displayed pictures need to change frequently. I've got the triggering and so forth all set up.</p>
  
  <p>Sometimes, a single shape will need to display one of several different pictures. I'd like to just copy in the picture data from the "library" picture (embedded in another shape, hidden from the user) to that destination, but I can work around this by simply swapping in and out the picture objects.</p>
  
  <p>However, sometimes multiple shapes in the UI will need to display the <em>same</em> image, even while retaining their unique data (name, id, size, visibility, title, etc). The "swap" trick on that is prohibitive - I'd have to create fifty copies of every single "library" object, one for each instance in the UI that <em>might</em> need to take on that appearance.</p>
  
  <hr>
  
  <p>DESIDERATUM:</p>
  
  <p>So what I'd like to do is to simply have <em>one</em> library copy of those pictures, and be able to copy that image into the picture objects that are integrated into the UI.</p>
  
  <hr>
  
  <p>PROBLEM:</p>
  
  <p>I can't find how to do this.</p>
  
  <p>I can't find any field within the VBA data structures which corresponds to the "image" part of a picture object.</p>
  
  <p>CopyPicture() and then Paste() appears to work only when the destination for Paste() is an address (e.g Range("A1")), and then it creates a <em>new</em> picture object. But I don't want a new object, and I don't want to paste into a cell. I want to overwrite the image data of an existing picture object with the image data of another picture object.</p>
  
  <p>Duplicate() and similar routines are variations on the above - they create a <em>new</em> picture object. I've got particular events etc tied to the <em>existing</em> object, the destination object, whose image data I'm trying to change, so I have to change <em>its</em> image, not replace it with some newly created object every time.</p>
  
  <p>LoadPicture() - which goes via the hard drive rather than the clipboard (slower and, thus, less desirable) doesn't seem to work on shape objects, only OLEObjects. Would I have to change all those picture objects into ActiveX images? That's a whole lot of overhead for static pictures! And I expect all that disk reading &amp; writing will bog down the sheet noticably.</p>
  
  <p>ActiveX - I could change these picture objects into activeX image objects, then change  the 'library' objects, and then use an assignement (Shapes("Name").DrawingObject.Object.Picture = Shape("Library").DrawingObject.Object.Picture). [This approach is along the lines of the approach here - <a href="https://stackoverflow.com/questions/7719450/excel-vba-copying-pictures-from-image-controls-to-active-x-objects">Excel VBA: Copying Pictures from image controls to activeX objects</a> ] I'm not sure I can make that work for my situation. Not only have I already designed much of the UI to take advantage of characteristics and functionality which Shape/Pictures have and OLEObjects do not (such as 3d formatting and the particular way 'fill' works on a picture object), but also manipulating OLEObjects is <em>markedly</em> slower than manipulating simple pictures, enough, in my implementation, to be frustrating to the user. (That's the one of the main reasons I switched away from using OLEObjects in an earlier stage of development.]</p>
  
  <hr>
  
  <p>Essentially, I want to do the equivalent of the "Change Picture" command one gets when right-clicking on a picture object (except getting the image data from another picture object or, if necessary, the clipboard, not from a file on disk). But when I record a macro of that action it comes up empty - apparently "Change Picture" doesn't produce any macro code.</p>
  
  <p>A whole bunch of web searching and documentation browsing hasn't turned up anything else.</p>
  
  <hr>
  
  <p>um.... help?</p>