Discussion:
Need macro to set all pictures in document to a certain size
(too old to reply)
oli merge
2007-03-20 16:15:31 UTC
Permalink
Hi,

i need a macro to set all pics to a certain size (in this case 4.5cm high
and 2.81cm wide).

I have tried resizing the pictures to the desired size manually first but
its no good because i cant find a prgram to do it that is free and doesnt
have limits on quality or amount of pictures in batch.

I already have a macro to resize all pics to a percentage of the original
size, so if you just tell me how to set an absolute size I can adapt that.

thanks
Lene Fredborg
2007-03-20 20:29:11 UTC
Permalink
Below you will find a macro that resizes all pictures in the active document
to the size you specified.

NOTE: If your pictures are not in the text layer (wrapping style “In line
with text” - set via Format > Picture > Layout tab) but floating (any other
wrapping style), you must change the “Dim…” line and the “For each…” line to
the following:

Dim oShape As Shape
For Each oShape In ActiveDocument.Shapes

The macro:

Sub ResizePictures()

Dim oShape As InlineShape
For Each oShape In ActiveDocument.InlineShapes
With oShape
'Change msoFalse to msoTrue to scale proportionally
.LockAspectRatio = msoFalse
.Width = CentimetersToPoints(2.81)
.Height = CentimetersToPoints(4.5)
End With
Next oShape
End Sub
--
Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
Post by oli merge
Hi,
i need a macro to set all pics to a certain size (in this case 4.5cm high
and 2.81cm wide).
I have tried resizing the pictures to the desired size manually first but
its no good because i cant find a prgram to do it that is free and doesnt
have limits on quality or amount of pictures in batch.
I already have a macro to resize all pics to a percentage of the original
size, so if you just tell me how to set an absolute size I can adapt that.
thanks
oli merge
2007-03-21 09:01:02 UTC
Permalink
cheers for your help lene. i ended up cheating and using .width = 87 etc
until I found the right dimensions, but I see now I could have just used the
centrimetres to points command.

Thanks again
Post by Lene Fredborg
Below you will find a macro that resizes all pictures in the active document
to the size you specified.
NOTE: If your pictures are not in the text layer (wrapping style “In line
with text” - set via Format > Picture > Layout tab) but floating (any other
wrapping style), you must change the “Dim…” line and the “For each…” line to
Dim oShape As Shape
For Each oShape In ActiveDocument.Shapes
Sub ResizePictures()
Dim oShape As InlineShape
For Each oShape In ActiveDocument.InlineShapes
With oShape
'Change msoFalse to msoTrue to scale proportionally
.LockAspectRatio = msoFalse
.Width = CentimetersToPoints(2.81)
.Height = CentimetersToPoints(4.5)
End With
Next oShape
End Sub
--
Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
Post by oli merge
Hi,
i need a macro to set all pics to a certain size (in this case 4.5cm high
and 2.81cm wide).
I have tried resizing the pictures to the desired size manually first but
its no good because i cant find a prgram to do it that is free and doesnt
have limits on quality or amount of pictures in batch.
I already have a macro to resize all pics to a percentage of the original
size, so if you just tell me how to set an absolute size I can adapt that.
thanks
Continue reading on narkive:
Loading...