Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Thread Tools Display Modes
Old 01-20-2006, 08:55 AM
Lor66 Lor66 is offline
Autosizing picture to fit a cell
Join Date: Jan 2006
Posts: 1
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
Old 12-05-2008, 07:33 PM
Emily Emily is offline
Join Date: Dec 2008
Location: Hong Kong
Posts: 7
Emily is on a distinguished road

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

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

Other Forums: Access Forums

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

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2021 DragonByte Technologies Ltd. is not affiliated with Microsoft