• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA code to copy Shape properties

spdemmon

New Member
Is there an easy way to copy the fill properties (i.e. gradient, colors, patterns, etc.) from 1 shape to another?


I thought it would be as easy as, but received an error

Set toShape = Sheets("Sheet1").Shapes(1).Fill

Set FroShape = Sheets("Sheet2").Shapes(2).Fill


toShape.Fill = FroShape.Fill
 
Hi ,


Use :


Sheets("Sheet2").Shapes(1).Fill.ForeColor = Sheets("Sheet1").Shapes(1).Fill.ForeColor


This assumes that the two shapes on the two sheets are both the first inserted shapes. Otherwise you need to change the index number for Shapes accordingly.


Narayan
 
Narayan, thank you for your response and afterwards realized what a poor job I had done in explaining what I was trying to really accomplish. Basically I want to copy all of the properties from 1 shape to another. So I was looking for either a way to loop thru all the properties and/or a higher level object where all the properties could be copied.


I'm trying to take 1 shape, read the properties primarily the gradient, color, and transparency and then apply those to another shape using VBA.


Again, any direction is greatly appreciated.
 
Although I wasn't able to simply copy I was able to brute force it by simply determining if a gradient existed and then copy each attribute.


Thank you again for the help.
 
Back
Top