View Single Post
 
Old 01-11-2017, 05:31 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,338
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

If you format the table so the cell into which the pictures are to go has a fixed cell height and width, any pictures not already in the document that you insert into those cells will automatically be constrained to fit the space available.

To apply a fixed height and width:
• For the rows, set the exact row height under Table Tools>Layout>Properties>Row>Specify Height>Exactly.
• For the columns, set the preferred column width under Table Tools>Layout>Properties>Columns and uncheck the 'automatically resize to fit contents' option under Table Tools>Layout>Properties>Table>Options

Having done that for the table, the following macro with resize the existing pictures in the cells concerned.
Code:
Sub ResizePics()
Application.ScreenUpdating = False
Dim r As Long, sWdth As Single, sHght As Single
With Selection
  If .Information(wdWithInTable) = True Then
  With .Tables(1)
    With .Cell(2, 1)
      sWdth = .Width: sHght = .Height
    End With
    For r = 2 To .Rows.Count
      With .Cell(r, 1).Range
        If .InlineShapes.Count > 0 Then
          With .InlineShapes(1)
            .LockAspectRatio = True
            .Width = sWdth
            If .Height > sHght Then .Height = sHght
          End With
        End If
      End With
    Next
  End With
End With
Application.ScreenUpdating = True
End Sub
Note: the macro assumes the first fixed-dimension cell the images are to be constrained to is the first one on the second row of the selected table. If it isn't, change both instances of '2' in the code to the correct row #.

For PC macro installation & usage instructions, see: http://www.gmayor.com/installing_macro.htm
For Mac macro installation & usage instructions, see: http://word.mvps.org/Mac/InstallMacro.html
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote