#1
|
|||
|
|||
Autosizing picture to fit a cell
What I have done is merge a large number of cells together to form one large cell for the purpose of adding pictures to the spreadsheet. However, some of the pictures are larger than the cell. What I would like to do it format the cell somehow so that any picture placed within it will auto resize to fit within the cell. Ideally, it should be easy for the user to add a picture into the cell. In other words, it will not do if the use has to insert a picture, then go through the process of resizing it to fit the cell; the picture needs to automatically adjust in size when placed withing the given cell.
Any ideas? Much thanks |
#2
|
|||
|
|||
Code:
Sub TestInsertPictureInCell() InsertPictureInRange "D:\Happy1.jpg", Range("A1") End Sub Sub InsertPictureInRange(PictureFileName As String, TargetCells As Range) Dim p As Object If Dir(PictureFileName) = "" Then Exit Sub Set p = ActiveSheet.Pictures.Insert(PictureFileName) With TargetCells p.Top = .Top p.Left = .Left .ColumnWidth = .ColumnWidth / .Width * p.Width .RowHeight = p.Height ' < 409 pixels End With Set p = Nothing End Sub |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Referencing a Captioned Picture | ComcoDG | Word | 0 | 11-10-2008 04:40 PM |
Drop down box in a cell | Grapejuice | Excel | 0 | 10-22-2007 07:40 PM |
highlight cell after checkbox | flatk | Word | 0 | 01-25-2007 12:32 PM |
click a cell to go to a worksheet | victor | Excel | 0 | 10-27-2006 02:57 PM |
Picture Button in Outlook Contact Form | Ahmad Dorji | Outlook | 0 | 02-17-2006 05:06 PM |