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

Positive and Negative Colors in a Chart

When creating a line cart, the line can show values both positive and negative values. This tip explains how you can use ...

Discover More

Creating a Hyperlink to a Specific Page

Most people add hyperlinks in a document to reference pages on the Web. You can, however, create hyperlinks to other Word ...

Discover More

Automatically Moving from Cell to Cell when Entering Data

As you enter data in a worksheet, you may want to have Excel automatically move from cell to cell based on the length of ...

Discover More

Learning Made Easy! Quickly teach yourself how to format, publish, and share your content using Word 2013. With Step by Step, you set the pace, building and practicing the skills you need, just when you need them! Check out Microsoft Word 2013 Step by Step today!

More WordTips (menu)

Understanding Object Anchors

Do you have documents that contain objects? Understanding how Word handles objects and the way they are anchored can make ...

Discover More

Displaying Thumbnails and Full-Size Images

Sometimes images can be just too big to display in a document. Instead you may want to display a smaller, thumbnail-size ...

Discover More

Adjusting Shadow Settings

Insert a graphic into a document and Word allows you to add a shadow behind the graphic. You can also adjust the ...

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 6 - 0?

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.