Welcome toWord.Tips.Net
Ask a Word Question
Make a Comment
Learn Access Now
Free Printable Forms
Beauty Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Legal Tips
Money Tips
Organizing Tips
Pest Tips
Pet Tips
Wedding Tips
Word2007 Tips
WordTips
Collapsing and Expanding Subdocuments
You have worked long and hard on your page design, including a couple of tables that are just right. Then, along comes a need to add a bit more text into one of the tables. The result is that the text in a cell wraps and pushes everything else down a bit. Now your whole design is thrown off! You long for a way to automatically adjust the size of the text in a cell so you won't have the wrapping and pushing occur.
If you are using Word 2000, Word 2002, or Word 2003 there is a built-in option that may do the trick. Simply follow these steps:
This same option is available in Word 2007 by following these steps:
What Word does is to decrease the apparent size of the text so that everything fits. Word decreases the width of the text by "scrunching" (a highly technical term) the text together horizontally, without adjusting it vertically.
If you are using Word 97, there is no inherent way to accomplish the task. Word doesn't provide any properties you can check to determine the width of various characters, each of which could be different sizes and have other attributes. You can, however, create a macro that may help you by displaying the width of a text string in points or inches. For instance, the following VBA macro displays an input box so you can input your string, displays the Font dialog box so you can specify font and point size, and then displays the width of the resulting string.
Sub GetStringLength()
Dim sngInitPos As Single
Dim sngEndPos As Single
Dim strText As String
Dim sngLength As Single
strText = InputBox("Enter the string whose length you want to determine")
Documents.Add
Dialogs(wdDialogFormatFont).Show
sngInitPos = Selection.Information(wdHorizontalPositionRelativeToPage)
Selection.InsertAfter strText
Selection.EndOf
sngEndPos = Selection.Information(wdHorizontalPositionRelativeToPage)
sngLength = sngEndPos – sngInitPos
MsgBox "Your string has a length of " & sngLength & _
" points, or " & PointsToInches(sngLength) & " inches."
ActiveDocument.Close savechanges:=False
End Sub
The only difficulty with this macro, of course, is that it isn't "automatic." For instance, it won't adjust the size of a text string to the maximum size possible to fit within a cell. In the long run it may be easier to just experiment with different font sizes for information in the cell until you find the right size for your needs.
Tip #3780 applies to Microsoft Word versions: 97 2000 2002 2003 2007
More Power! For some people, the prospect of creating Word macros can be scary. WordTips: The Macros can help you conquer your fears and you'll discover you're much more confident and productive as you make Word do exactly what you want. This is an invaluable source for learning macros. You are introduced to the topic in bite-sized chunks, pulled from past issues of WordTips. Learn at your own pace, exactly the way you want.