Consulting

Results 1 to 4 of 4

Thread: anchor picture to cell

  1. #1
    VBAX Mentor
    Joined
    Oct 2007
    Posts
    372
    Location

    anchor picture to cell

    Hello,

    I have a picture (logo) that goes on every sheet of a workbook with numerous sheets. Because it looks ridiculous for the image to be a different size on each one, I am trying to figure out a way to just anchor the image to a cell so that it will not only be in the correct place inspite of someone inserting rows above or below but also will be of a consistent size.

    I appreciate any ideas.

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Is code even needed? You can set it not to resize by right clicking it > Format Control > Properties > Don't Move or Size with Cells.

  3. #3
    VBAX Mentor
    Joined
    Oct 2007
    Posts
    372
    Location
    Well, I don't know that code is needed. The problem with doing it the way you describe is I'll have to do that every time I put the image in. I was looking for something that doesn't involve right clicking and editing the properties of the image every single time since the size / shape is the same every time.

    I was wondering if it were possible to just put the image on a hidden sheet and references it so I don't have to actually store 20 images in a workbook.

  4. #4
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    You could add it as a link. I would put the images in a picture folder or the current workbook's folder.

    This example shows how you could add one for the current sheet. You could easily add it to iterate a number of sheets.
    [VBA] ActiveSheet.OLEObjects.Add(ThisWorkbook.Path & "\ken.jpg", Link:=True, _
    DisplayAsIcon:=False, Left:=252.75, Top:=90.75, Width:=162, Height:= _
    126.75).Select
    With Selection
    .Placement = xlFreeFloating
    .PrintObject = True
    End With
    Range("A1").Select[/VBA]

Posting Permissions

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