+ Reply to Thread
Results 1 to 7 of 7

Positioning pictures in a cell

  1. #1
    ZipCurs
    Guest

    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. #2
    Tim Williams
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    >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. #3
    Tom Ogilvy
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    > 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. #4
    K Dales
    Guest

    RE: 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. #5
    K Dales
    Guest

    RE: 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. #6
    ZipCurs
    Guest

    Re: 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" <[email protected]> wrote in message
    > news:[email protected]...
    > > 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. #7
    ZipCurs
    Guest

    RE: 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1