Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a table with pictures (jpegs) and descriptions. I would like to use a
macro to insert the picture in the cell next to the description and center it in the cell. I can easily get it near the cell, but I can't seem to find a way to position the picture exactly where it want it. Any help appreciated. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try looking at the "TopLeftCell" property (applies to your pictures).
Alternatively, if you really need to center the picture, cells have top, left, height and width properties which you can use to position your pics. Tim "ZipCurs" wrote in message ... I have a table with pictures (jpegs) and descriptions. I would like to use a macro to insert the picture in the cell next to the description and center it in the cell. I can easily get it near the cell, but I can't seem to find a way to position the picture exactly where it want it. Any help appreciated. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The picture is always smaller than the cell?
with activesheet.Shapes("Picture1") .Top = range("B9").Top + ( range("B9").Height - .height)/2 .Left = range("B9").Left + (range("B9").Width - .Width)/2 End With -- Regards, Tom Ogilvy "ZipCurs" wrote in message ... I have a table with pictures (jpegs) and descriptions. I would like to use a macro to insert the picture in the cell next to the description and center it in the cell. I can easily get it near the cell, but I can't seem to find a way to position the picture exactly where it want it. Any help appreciated. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Both cells and pictures have .Top and .Left properties, that define their
location, and .Width and .Height properties that define their size. For example, if I wanted to put a picture (MyPic) inside cell B2, have it sized at 90% of the cell size and be centered in the cell, this is what I would do: With Range("B2") MyPic.Width = 0.9 * .Width MyPic.Height = 0.9 * .Height MyPic.Top = .Top + 0.05 * .Height ' For picture 90% of height, this will center it top to bottom MyPic.Width = .Left + 0.05 * .Width End With (Note this assumes the aspect ratio of the picture is not locked. It is possible to do the reverse: to fit the cell to the size of the picture) -- - K Dales "ZipCurs" wrote: I have a table with pictures (jpegs) and descriptions. I would like to use a macro to insert the picture in the cell next to the description and center it in the cell. I can easily get it near the cell, but I can't seem to find a way to position the picture exactly where it want it. Any help appreciated. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hit Close before I fixed a mistake I spotted: last line before End With
should be MyPic.Left=, not MyPic.Width= -- - K Dales "ZipCurs" wrote: I have a table with pictures (jpegs) and descriptions. I would like to use a macro to insert the picture in the cell next to the description and center it in the cell. I can easily get it near the cell, but I can't seem to find a way to position the picture exactly where it want it. Any help appreciated. |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Tom,
Exactly what I needed, thanks!!! "Tom Ogilvy" wrote: The picture is always smaller than the cell? with activesheet.Shapes("Picture1") .Top = range("B9").Top + ( range("B9").Height - .height)/2 .Left = range("B9").Left + (range("B9").Width - .Width)/2 End With -- Regards, Tom Ogilvy "ZipCurs" wrote in message ... I have a table with pictures (jpegs) and descriptions. I would like to use a macro to insert the picture in the cell next to the description and center it in the cell. I can easily get it near the cell, but I can't seem to find a way to position the picture exactly where it want it. Any help appreciated. |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Very helpful, Thanks
"K Dales" wrote: Both cells and pictures have .Top and .Left properties, that define their location, and .Width and .Height properties that define their size. For example, if I wanted to put a picture (MyPic) inside cell B2, have it sized at 90% of the cell size and be centered in the cell, this is what I would do: With Range("B2") MyPic.Width = 0.9 * .Width MyPic.Height = 0.9 * .Height MyPic.Top = .Top + 0.05 * .Height ' For picture 90% of height, this will center it top to bottom MyPic.Width = .Left + 0.05 * .Width End With (Note this assumes the aspect ratio of the picture is not locked. It is possible to do the reverse: to fit the cell to the size of the picture) -- - K Dales "ZipCurs" wrote: I have a table with pictures (jpegs) and descriptions. I would like to use a macro to insert the picture in the cell next to the description and center it in the cell. I can easily get it near the cell, but I can't seem to find a way to position the picture exactly where it want it. Any help appreciated. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Positioning charts & pictures with data for printing | Excel Discussion (Misc queries) | |||
Positioning all pictures | Excel Discussion (Misc queries) | |||
Positioning an Object (say a box) on a Excel cell | Excel Programming | |||
Positioning a cell at the top left of the screen | Excel Programming | |||
Positioning copied pictures | Excel Programming |