Microsoft Office Forums Autofit Image to a Preset Cell

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-01-2011, 05:20 AM
GarethHourihane GarethHourihane is offline Autofit Image to a Preset Cell Windows Vista Autofit Image to a Preset Cell Office 2003
Novice
Autofit Image to a Preset Cell
 
Join Date: Jun 2011
Posts: 4
GarethHourihane is on a distinguished road
Question Autofit Image to a Preset Cell

Hi

I'm currently working on a photograph template for inclusion in a survey report.



What I have currently is a page with 2 cells for inserting images into. The problem is that whenever a photo is inserted it doesnt auto fill to the size of the cell. The photo retains it's original size.

Is there a way in which I can insert an image into a cell and regardless of what size the image was it will fill the cell?

Thanks , G
Reply With Quote
  #2  
Old 06-01-2011, 08:10 PM
macropod's Avatar
macropod macropod is offline Autofit Image to a Preset Cell Windows 7 32bit Autofit Image to a Preset Cell Office 2007
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,525
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

Hi Gareth,

Have you fixed the cell sizes to specified exact heigh and widths? Have you unchecked the table's 'automatically resize cells to fit contents' option?

Are you inserting the images directly into the cells from a file via Insert|Picture (or by dragging & dropping from the folder into the table), or are you dragging & dropping them from elsewhere in the document - the latter circumvents the resizing.
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #3  
Old 06-01-2011, 11:52 PM
GarethHourihane GarethHourihane is offline Autofit Image to a Preset Cell Windows Vista Autofit Image to a Preset Cell Office 2003
Novice
Autofit Image to a Preset Cell
 
Join Date: Jun 2011
Posts: 4
GarethHourihane is on a distinguished road
Default

Hi Paul - Thanks for the response.

Cell size is fixed at 17cm x 9cm and 'automatically resize cells to fit contents' is unchecked.

The image is being inserted via insert / picture from file too.

It appears to work when inserting an image that is larger than the cell size - but not when an image is smaller.
Reply With Quote
  #4  
Old 06-02-2011, 01:08 AM
macropod's Avatar
macropod macropod is offline Autofit Image to a Preset Cell Windows 7 32bit Autofit Image to a Preset Cell Office 2007
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,525
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

Hi Gareth,

AFAIK, that's how it's meant to work - the cell constrains the maximum image size, but not the minimum.
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #5  
Old 06-02-2011, 02:41 AM
GarethHourihane GarethHourihane is offline Autofit Image to a Preset Cell Windows Vista Autofit Image to a Preset Cell Office 2003
Novice
Autofit Image to a Preset Cell
 
Join Date: Jun 2011
Posts: 4
GarethHourihane is on a distinguished road
Default

So when inserting an image into a cell is there no way of forcing the image to fill the cell, regardless of whether it's decreasing or increasing the original size?

Thanks
Reply With Quote
  #6  
Old 06-02-2011, 03:02 AM
macropod's Avatar
macropod macropod is offline Autofit Image to a Preset Cell Windows 7 32bit Autofit Image to a Preset Cell Office 2007
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,525
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

Hi Gareth,

As I'm sure you've found, over-sized images are reduced in size. So, it's really only the under-sized images that are the problem. Regardless, the following macro will fit all inlineshapes in all cells in all tables to the 'best fit' for the cells they're in.

Code:
Sub FitPics()
Application.ScreenUpdating = False
Dim Tbl As Table, iShp As InlineShape
With ActiveDocument
  For Each Tbl In .Tables
    For Each iShp In Tbl.Range.InlineShapes
      With iShp
        .LockAspectRatio = msoTrue
        .Height = .Range.Cells(1).Height
        If .Width > .Range.Cells(1).Width Then
          .Width = .Range.Cells(1).Width
        End If
      End With
    Next
  Next
End With
Application.ScreenUpdating = True
End Sub
Note: As coded, the macro takes no account of cell border padding or any 'before/after' spacing for the paragraph they're attached to.
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #7  
Old 06-02-2011, 05:05 AM
GarethHourihane GarethHourihane is offline Autofit Image to a Preset Cell Windows Vista Autofit Image to a Preset Cell Office 2003
Novice
Autofit Image to a Preset Cell
 
Join Date: Jun 2011
Posts: 4
GarethHourihane is on a distinguished road
Default

Spot on Paul. Thanks very much.
Reply With Quote
Reply

Tags
autofit, fill, image

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Autofit Image to a Preset Cell Adding Image into a excel cell and adding a hyperlink to the image saravananiyyanar Excel 3 05-04-2011 08:31 AM
How can I fill cell color starting from Cell D5 using Conditional formatting instead Learner7 Excel 0 07-08-2010 05:50 AM
How can I make a cell color RED under the Today's date cell? Learner7 Excel 2 07-08-2010 12:52 AM
Auto-populate an MS Word table cell with text from a diff cell? dreamrthts Word Tables 0 03-20-2009 01:49 PM
Table Autofit Behavior Default Henri Blits Word Tables 0 07-18-2006 03:49 PM


All times are GMT -7. The time now is 10:18 PM.


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