View Single Post
 
Old 11-24-2024, 02:20 PM
macropod's Avatar
macropod macropod is offline Windows 10 Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
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

OK, make sure you have set the preferred width for the nested table and its column to however many inches/centimeters you require.

Then, for the cell, check the 'fit text' property. This will stop the cell expanding but may result in parts of pictures that are wider than the cell when fitted to the row height disappearing. The following macro will correct such images after they're inserted.

You can select either a single cell or a whole table for processing - which means to can leave the resizing till the end.

Fiddling with the 'fit text' property isn't really necessary, but it prevents the rest of the parent cell's layout being messed with before the macro is run.

Code:
Sub FitPics()
Dim Tbl As Table, TblCl As Cell, Cell As Cell, i As Long, sWdth As Single
With Selection
  If .Information(wdWithInTable) = False Then Exit Sub
  For Each Cell In .Cells
    With Cell
      sWdth = .PreferredWidth
      For i = 1 To .Range.InlineShapes.Count
        With .Range.InlineShapes(i)
          .LockAspectRatio = True
          If .Width > sWdth Then .Width = sWdth
        End With
      Next
    End With
    For Each Tbl In Cell.Tables
      For Each TblCl In Tbl.Range.Cells
        With TblCl
          sWdth = .PreferredWidth
          For i = 1 To .Range.InlineShapes.Count
            With .Range.InlineShapes(i)
              .LockAspectRatio = True
              If .Width > sWdth Then .Width = sWdth
            End With
          Next
        End With
      Next
    Next
  Next
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote