Photo alignment within a cell
-
- SilverLounger
- Posts: 1868
- Joined: 25 Jan 2010, 14:00
- Location: Conroe, Texas
Photo alignment within a cell
Is it possible when inserting a photo with the use of code to have photo align bottom center of cell.
-
- Microsoft MVP
- Posts: 87
- Joined: 10 Mar 2011, 05:38
- Status: Microsoft MVP
- Location: New Jersey in the US
Re: Photo alignment within a cell
Try this sub (read the comments)...
Note that if you already have the picture on the worksheet and are only going to move it, you will need to put in some error-trapping code to protect against the picture not being able to fit in the desired location. If, on the other hand, you use the code above, the picture will be placed as close to the desired location as possible without raising any error.
Â
Code: Select all
Sub AddPictureCenterBottomActiveCell()
' If you already have the picture on the worksheet, then add code to select
' it here in place of this next line of code (which inserts a new picture).
ActiveSheet.Pictures.Insert("C:\Temp\SomePictureName.bmp").Select
' Move the selected picture into place with respect to the active cell
Selection.Top = ActiveCell.Top + ActiveCell.Height - Selection.Height
Selection.Left = ActiveCell.Left - (Selection.Width - ActiveCell.Width) / 2
End Sub
Â
-
- SilverLounger
- Posts: 1868
- Joined: 25 Jan 2010, 14:00
- Location: Conroe, Texas
Re: Photo alignment within a cell
Thank You