I have a chart in a spreadsheet that I want to copy as a bitmap and place somewhere else within the same sheet. My code is below, although there's not much to see. No matter what I change .width to, the width of the chart does not adjust to what I tell it to. However, the width will change if I change .Height. This indicates that the pasted Bitmap image insists on retaining its original proportions.
Is this property specific to Bitmap objects, and is there a way around this problem without changing the paste format to something other than Bitmap?
Thanks for your help.
Set AB = ActiveSheet.Shapes(ActiveSheet.Shapes.Count)
With AB
.Left = ActiveSheet.Range("AB1").Left
.Top = ActiveSheet.Range("AB1").Top
.Width = ActiveSheet.Range("AB100:BM100").Width
.Height = ActiveSheet.Range("AB1:AB50").Height
End With
I'm guessing the bitmap you pasted has "Lock Aspect Ratio" set (Format Picture -> Size & Properties). In this case, Excel will change the Width of the bitmap after you set the Height (to preserve the bitmap's aspect ratio).
Use .LockAspectRatio = msoFalse before you set the Height and Width properties.