Todd said:
In a title in Powerpoint, if the title gets a little too long, the font
size
is reduced automatically. I want to do the same thing in Word. I don't
want
the text to wrap or the container to change size, I just want the font to
get
smaller. Is there a way, inside of a text box or a table cell or some area
to
get Word to perform and automatic font size adjustment?
Thanks in advance,
Hi Todd,
Not quite a substitute for an automatic font size adjustment, but below's a
macro that should work in regular text, text boxes, and in table cells that
have a specified width.
No guarantees... having written it just now.
Regards,
Klaus
Sub FitPara()
Dim rngStart As Range
Dim rngEnd As Range
Dim rngPara As Range
Set rngPara = Selection.Paragraphs(1).Range
Set rngStart = Selection.Paragraphs(1).Range.Characters.First
Set rngEnd = Selection.Paragraphs(1).Range.Characters.Last
rngEnd.MoveWhile Cset:=Chr(13) & Chr(11) & Chr(7), Count:=wdBackward
rngEnd.Collapse (wdCollapseStart)
If Selection.Paragraphs(1).Range.Font.Size = wdUndefined Then
MsgBox "Paragraph does not have uniform font size", vbExclamation,
"Macro cancelled:"
Exit Sub
End If
If rngEnd.start <= rngStart.start Then
MsgBox "No paragraph to fit was found", vbExclamation, "Macro
cancelled:"
Exit Sub
End If
While rngStart.Information(wdVerticalPositionRelativeToTextBoundary) = _
rngEnd.Information(wdVerticalPositionRelativeToTextBoundary)
rngPara.Font.Size = rngPara.Font.Size * 2
Wend
While rngStart.Information(wdVerticalPositionRelativeToTextBoundary) <> _
rngEnd.Information(wdVerticalPositionRelativeToTextBoundary)
rngPara.Font.Size = rngPara.Font.Size / 1.2
Wend
While rngStart.Information(wdVerticalPositionRelativeToTextBoundary) = _
rngEnd.Information(wdVerticalPositionRelativeToTextBoundary)
rngPara.Font.Size = rngPara.Font.Size * 1.05
Wend
While rngStart.Information(wdVerticalPositionRelativeToTextBoundary) <> _
rngEnd.Information(wdVerticalPositionRelativeToTextBoundary)
rngPara.Font.Size = rngPara.Font.Size / 1.005
Wend
End Sub