![]() |
|
#1
|
||||
|
||||
![]() Such labels are usually generated via a mailmerge, in which case, see: https://www.msofficeforums.com/125792-post2.html Otherwise, try the following macro: Code:
Sub Demo() Application.ScreenUpdating = False Dim Tbl As Table, Cll As Cell, Par As Paragraph, sCllWdth As Single, sParWdth As Single With ActiveDocument For Each Tbl In .Tables With Tbl With .Cell(1, 1) sCllWdth = .Width - .LeftPadding - .RightPadding End With For Each Cll In .Range.Cells With Cll .WordWrap = False If Len(.Range) > 2 Then For Each Par In .Range.Paragraphs With Par.Range sParWdth = .Characters.Last.Previous.Information(wdHorizontalPositionRelativeToPage) sParWdth = sParWdth - .Characters.First.Information(wdHorizontalPositionRelativeToPage) If sParWdth + Par.LeftIndent > sCllWdth Then .FitTextWidth = sCllWdth - Par.LeftIndent If .Characters.Last.Previous.Information(wdVerticalPositionRelativeToPage) <> _ .Characters.First.Information(wdVerticalPositionRelativeToPage) Then .FitTextWidth = sCllWdth - Par.LeftIndent End If End With Next End If End With Next End With Next End With Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
thomasoj | Word VBA | 3 | 01-15-2020 06:26 AM |
VBA - change font and font size for Word footnote | thomasoj | Word VBA | 1 | 01-15-2020 02:37 AM |
![]() |
WH7262 | Word VBA | 1 | 08-26-2014 03:46 PM |
![]() |
kkepo | Word | 4 | 08-28-2012 08:53 PM |
![]() |
14spar15 | Word | 1 | 11-13-2011 11:17 PM |