PDA

View Full Version : How to miniaturize many images in document?



akokin
11-02-2007, 05:53 AM
There is one document which contain many images. How I can to miniaturize of all images to 50%?
Thank you!

fionabolt
11-02-2007, 09:19 AM
This works in 2003 - in 2007 it'll be different I think

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

akokin
11-02-2007, 09:32 AM
Thank you very much! It's good worked!

TonyJollans
11-02-2007, 09:56 AM
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 ...

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

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.

TonyJollans
11-02-2007, 09:57 AM
Seems I was beaten to it :)

akokin
11-06-2007, 05:35 AM
TonyJollans, thank you!