Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default Positioning pictures in a cell

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Positioning pictures in a cell

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Positioning pictures in a cell

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Positioning pictures in a cell

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Positioning pictures in a cell

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default Positioning pictures in a cell

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default Positioning pictures in a cell

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Positioning charts & pictures with data for printing Papermaker Excel Discussion (Misc queries) 0 November 4th 08 04:36 PM
Positioning all pictures gejmond Excel Discussion (Misc queries) 3 June 26th 06 08:48 PM
Positioning an Object (say a box) on a Excel cell Ken Excel Programming 3 October 5th 05 05:47 AM
Positioning a cell at the top left of the screen Ben Excel Programming 4 May 14th 05 01:22 PM
Positioning copied pictures keepitcool Excel Programming 2 May 26th 04 02:25 PM


All times are GMT +1. The time now is 08:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"