Insert picture using Macro..
You need to get the height and width of the cell is is going into to center
the cell
CellHeight = range("A1").Height
CellWidth = range("A1").Width
pict.LockAspectRatio = msoTrue
if pict.width pict.height then
pict.width = 100
else
pict.height = 100
end if
WidthBorder = CellWidth - pict.width
pict.left = Range("A1").left + WidthBorder/2
HeightBorder = CellHeight - pict.height
pict.top = Range("A1").Top + HeightBorder/2
" wrote:
On Jun 18, 2:07 pm, wrote:
On Jun 18, 11:20 am, Joel wrote:
You need to get the larger of the width or height variable and adjust it to 100
pict.LockAspectRatio = msoTrue
if pict.width pict.height then
pict.width = 100
else
pict.height = 100
end if
" wrote:
I have a macro that I use to insert pictures in excel but I am having
difficulty with the picture size, I would like the picture to keep the
Aspect Ratio but to have a maximum of 100 height and a maximum 100
width is this possible, any help is appreciated.
Thanks.- Hide quoted text -
- Show quoted text -
Thanks, you are great!.
Is there any way that I can center the pictures in the cell, because
when the width is than the height it ia scaling it to 100 but then
it is being placed slightly on the cell in to the left.
thanks- Hide quoted text -
- Show quoted text -
Hi,
I am wondering if this will work! I tried but it seems that I am doing
something wrong can you help please.
pict.LockAspectRatio = msoTrue
if pict.width pict.height then
pict.cropleft = 50
pict.cropright = 50
else
pict.height = 100
end if
|