Please Note: This article is written for users of the following Microsoft Word versions: 97, 2000, 2002, and 2003. If you are using a later version (Word 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Word, click here: Scaling Graphics in a Macro.

Scaling Graphics in a Macro

Written by Allen Wyatt (last updated February 5, 2022)
This tip applies to Word 97, 2000, 2002, and 2003


2

You may have a need to routinely scale graphics in your document by a certain percentage. Using the menus to do the scaling can get tiresome, so you may want to do the scaling by using a macro you can assign to a toolbar button or a shortcut key. The following macro will handle doing the scaling very nicely:

Sub PictSize()
    Dim PercentSize As Integer

    PercentSize = InputBox("Enter percent of full size", _
      "Resize Picture", 75)

    If Selection.InlineShapes.Count > 0 Then
        Selection.InlineShapes(1).ScaleHeight = PercentSize
        Selection.InlineShapes(1).ScaleWidth = PercentSize
    Else
        Selection.ShapeRange.ScaleHeight Factor:=(PercentSize / 100), _
          RelativeToOriginalSize:=msoCTrue
        Selection.ShapeRange.ScaleWidth Factor:=(PercentSize / 100), _
          RelativeToOriginalSize:=msoCTrue
    End If
End Sub

The macro first asks for a percentage by which you want to scale the selected image, offering 75 (75%) as the default. When you specify a percentage, the macro then checks to see if the selected graphic is an inline or a floating graphic. The reason for doing this is that the object specification is different in each case, as well as how the scaling is specified. Inline objects belong to the InlineShapes collection, while floating objects are set using the ShapeRange object.

If you want to resize all the graphics in your document by the same percentage, then you only need to modify the above macro so that it steps through each of the inline graphics and then each of the floating graphics.

Sub AllPictSize()
    Dim PercentSize As Integer
    Dim oIshp As InlineShape
    Dim oshp As Shape

    PercentSize = InputBox("Enter percent of full size", _
      "Resize Picture", 75)

    For Each oIshp In ActiveDocument.InlineShapes
        With oIshp
            .ScaleHeight = PercentSize
            .ScaleWidth = PercentSize
        End With
    Next oIshp

    For Each oshp In ActiveDocument.Shapes
        With oshp
            .ScaleHeight Factor:=(PercentSize / 100), _
              RelativeToOriginalSize:=msoCTrue
            .ScaleWidth Factor:=(PercentSize / 100), _
              RelativeToOriginalSize:=msoCTrue
        End With
    Next oshp
End Sub

Note:

If you would like to know how to use the macros described on this page (or on any other page on the WordTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (7694) applies to Microsoft Word 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Word (Word 2007 and later) here: Scaling Graphics in a Macro.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Starting Microsoft Graph

Microsoft Graph is a simplistic graphic tool that you can use to quickly add graphs to your document. Here's how to start ...

Discover More

Allowing Sentence Fragments

Grammar, particularly in English, has a perplexing array of rules and exceptions to those rules. Word does a fairly good ...

Discover More

Repeating Cell Contents

Want to repeat cell contents over and over again within a single cell? Excel provides two ways you can duplicate the content.

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More WordTips (menu)

Moving Object Anchors

When you insert an object into your document, it is anchored to a paragraph. If you want to change the paragraph to which ...

Discover More

Moving Drawing Objects

When you need to move a drawing object around your document, you use the mouse after you select the object. This tip ...

Discover More

Automatically Formatting Graphics and AutoShapes

Want to change the graphics formatting defaults in Word? You can customize some of these defaults, saving yourself some time.

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 1 + 1?

2022-10-15 13:54:07

David

Awesome! Is it also possible to scale the image to a percentage of the page width, e.g. to 100%? Word does not allow this for some reason, it's always greyed out: i.imgur.com/H7LrDiQ.png


2022-02-05 06:42:06

Daniel

Allen,

Thanks for this tip, but it's not very useful for my most common scenario. Mostly I am copying a web page into a Word document to nicely format and print the article (without all the garbage and bad formatting you get if you try to print a web page directly).

Most of the embedded images from the web page will be wider than my Word page size, but they often vary in width. So what I would like to be able to do with a macro is to change the WIDTH of all images in a document to some specified page width (e.g. 160mm for an A4 portrait page layout with 30+20mm in/out margins).

I hope the remaining removal work and return home all go smoothly!

Rgds,
Daniel


This Site

Got a version of Word that uses the menu interface (Word 97, Word 2000, Word 2002, or Word 2003)? This site is for you! If you use a later version of Word, visit our WordTips site focusing on the ribbon interface.

Videos
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.