Word

Stretch Text to Fit - Height or Width

Ease of Use

Easy

Version tested with

2000 

Submitted by:

mdmackillop

Description:

Increases the height of text while maintaining width or increases the width of text while maintaining the height. 

Discussion:

A simple way to manipluate text to fit into restricted areas, such as labels. 

Code:

instructions for use

			

Sub TextHeight() Dim OldSize As Double, NewSize As Double OldSize = Selection.Font.Size NewSize = InputBox("Enter new font size") With Selection.Font .Size = NewSize .Scaling = 100 * OldSize / NewSize End With End Sub Sub TextWidth() Dim OldSize As Double, NewSize As Double OldSize = Selection.Font.Size NewSize = InputBox("Enter new font size") With Selection.Font .Scaling = 100 * NewSize / OldSize End With End Sub

How to use:

  1. Copy the code above.
  2. Open the file in which you wish to use the text resizer.
  3. Hit Alt+F11 to open the Visual Basic Editor.
  4. Choose your document in the window at left.
  5. Choose Insert-Module, and paste the code into the window at the right.
  6. Hit the Save diskette button and close the VBE.
 

Test the code:

  1. Select the text to be modified.
  2. Hit Tools-Macro-Macros and double-click TextHeight or TextWidth
  3. Enter the Font size to which you wish to stretch your text.
 

Sample File:

textresizer.zip 4.81KB 

Approved by mdmackillop


This entry has been viewed 124 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2020 VBA Express