Adjust size of imported pictures

R

Robin Clay

Greetings !

I wanted to write a Macro to re-size every imported picture in the document
to 75%.

That's the real challenge.

So I tried to "Record a Macro" - but while recording I wasn't able to select
a picture !

....and that's the subsidiary challenge - WHY could I not ?


Regards

Robin
 
G

Graham Mayor

There are lots of things that cannot be captured in a macro using the
recorder. This is one of them.

The following should format pictures at 75% of their inserted size.

Dim aShape As Shape
Dim bShape As InlineShape
With ActiveDocument
For Each aShape In .Shapes
If aShape.Type = msoPicture Then
With aShape
.Height = .Height * 0.75
.Width = .Width * 0.75
.LockAspectRatio = msoTrue
End With
End If
Next
For Each bShape In .InlineShapes
If bShape.Type = wdInlineShapePicture Then
With bShape
.Height = .Height * 0.75
.Width = .Width * 0.75
.LockAspectRatio = msoTrue
End With
End If
Next
End With


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
R

Robin Clay

Thank you, Graham !

That looks pretty much what I wanted.

Just one slight niggle - when you put:-
.Height = .Height * 0.75

....that impies 75% of what it currently is, not of its original size.

Or have I missed something ?


There are lots of things that cannot be captured in a macro using the
recorder. This is one of them.

Pah ! I might have guessed..... ;-)


Regards

Robin
 
G

Graham Mayor

That is indeed what the macro does.

I am not sure if it is possible to return the original sizes of images. No
doubt someone will come along soon to tell me what I have overlooked ;)

It would be possble to set them all to the same finished width (the height
being determined by the aspect ratio of the picture), but the simplest way
to do that is to insert them into a table cell of fixed width in the first
place, or to size them correctly in a third party graphics application
before insertion.


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top