Consulting

Results 1 to 6 of 6

Thread: How to miniaturize many images in document?

  1. #1
    VBAX Regular
    Joined
    Aug 2007
    Posts
    66
    Location

    How to miniaturize many images in document?

    There is one document which contain many images. How I can to miniaturize of all images to 50%?
    Thank you!

  2. #2
    This works in 2003 - in 2007 it'll be different I think

    [VBA]Dim iShape As InlineShape
    For Each iShape In ActiveDocument.InlineShapes
    iShape.Height = iShape.Height * 0.5
    iShape.Width = iShape.Width * 0.5
    Next iShape
    [/VBA]

  3. #3
    VBAX Regular
    Joined
    Aug 2007
    Posts
    66
    Location
    Thank you very much! It's good worked!

  4. #4
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    I don't think you can do it all in one go - you have to do each picture individually. Pictures may be of two types - InlineShapes and Shapes and the two are, as you might expect, different and you will need two loops ...
    [vba]
    For Each pic In ActiveDocument.Content.InlineShapes
    If pic.Type = wdInlineShapePicture Then
    pic.Height = pic.Height / 2
    pic.Width = pic.Width / 2
    End If
    Next
    For Each pic In ActiveDocument.Content.ShapeRange
    If pic.Type = msoPicture Then
    pic.Height = pic.Height / 2
    If pic.LockAspectRatio = msoFalse Then
    pic.Width = pic.Width / 2
    End If
    End If
    Next
    [/vba]
    It seems as if the LockAspectRation of InlineShapes is ignored in code, whilst that of Shapes is honoured.

    If you are looking to make the document physically smaller you may want to look at crop options and/or compressing pictures - although, depending on version, that may not be as successful as you would wish.
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

  5. #5
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    Seems I was beaten to it
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

  6. #6
    VBAX Regular
    Joined
    Aug 2007
    Posts
    66
    Location
    TonyJollans, thank you!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •