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

Deleting Paragraph Borders

Got a document that has a border around some paragraphs? Here's how you can get rid of the border in the fastest way ...

Discover More

Determining the Current Directory

When creating macros, it is often necessary to know which directory is the default. Here's how you can find out by using ...

Discover More

Suppressing ASK Fields When Printing

Do you like using ASK Fields in your documents to get information from the user but don't want Word to update the fields ...

Discover More

Do More in Less Time! Are you ready to harness the full power of Word 2013 to create professional documents? In this comprehensive guide you'll learn the skills and techniques for efficiently building the documents you need for your professional and your personal life. Check out Word 2013 In Depth today!

More WordTips (menu)

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

Nudging a Graphic

If you need to move a graphic just a little bit in one direction or another, you can do so by using the techniques in ...

Discover More

Horizontal Alignment Errors for Graphics

Discussion of alignment differences for graphics in Word 97 and Word 2000.

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 two more than 7?

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.