Microsoft Office Forums

Go Back   Microsoft Office Forums > Microsoft Excel > Excel

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 01-20-2006, 08:55 AM
Novice
 
Join Date: Jan 2006
Posts: 1
Lor66
Default 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
Reply With Quote
  #2  
Old 12-05-2008, 07:33 PM
Novice
 
Join Date: Dec 2008
Location: Hong Kong
Posts: 7
Emily is on a distinguished road
Default

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
Reply With Quote
Reply

Thread Tools
Display Modes


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


All times are GMT -7. The time now is 01:41 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
MSOfficeForums.com is not affiliated with Microsoft