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

AutoFitting Tables

Need to adjust the width of a bunch of table columns according to what is in the columns? Word provides a tool to do ...

Discover More

Converting Endnotes to Regular Text

If you have a document with lots of endnotes, you may need them converted to regular text so that they can be used ...

Discover More

Quickly Customizing the Keyboard

Want a quick way to change the shortcut key associated with a tool available on a ribbon, toolbar, or menu? Here's one ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 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

Using the Drawing Grid

One of the lesser-known drawing tools provided in Word is the drawing grid. You can easily turn this feature on and use ...

Discover More

Rotating Graphics Around a Different Center Point

You use the rotation handle in Word 2002 and Word 2003 to, well, rotate graphics around a center point. But if you hold ...

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 8 - 5?

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.