I have a fairly simple macro writing question (in Word).

O

oli merge

I have used a mail merge to create labels of products with relevent pictures
attached to each label. However I have to select all and update to get the
images to appear once the merge has run and then the sizes all change to a
very small size.

I have made a macro to resize the images one at a time to 9% of the
original, but I cant find out how to resize all the images (about 300 this
time). Ideally I would like to resize them based on how many records were
merged, but i suppose it would work if i just did a loop for a static amount.

any ideas?? thanks
 
J

Jean-Guy Marcil

oli merge was telling us:
oli merge nous racontait que :
I have used a mail merge to create labels of products with relevent
pictures attached to each label. However I have to select all and
update to get the images to appear once the merge has run and then
the sizes all change to a very small size.

I have made a macro to resize the images one at a time to 9% of the
original, but I cant find out how to resize all the images (about 300
this time). Ideally I would like to resize them based on how many
records were merged, but i suppose it would work if i just did a loop
for a static amount.

any ideas?? thanks

You could loop through the shape collection.
Here are two examples, the first one is for floating pictures (With
Wrapping). The second one is for Inline Shapes (In line with text).
In both cases I added a test for the type of shape. It may not be necessary
if you know for a fact that your document does not have any other types of
shapes or inline shapes.

'_______________________________________
Sub LoopShapes()

Dim shpPix As Shape

For Each shpPix In ActiveDocument.Shapes
If shpPix.Type = msoPicture Then
'Do your stuff
End If
Next

End Sub
'_______________________________________

'_______________________________________
Sub LoopInLineShapes()

Dim ILshpPix As InlineShape

For Each ILshpPix In ActiveDocument.InlineShapes
If ILshpPix.Type = wdInlineShapePicture Then
'Do your stuff
End If
Next

End Sub
'_______________________________________

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
B

Brian

Try this.

Sub AllPictSize()
Dim PercentSize As Integer
Dim oIshp As InlineShape
Dim oshp As Shape
PercentSize = InputBox("Enter percent of full size", "Resize Picture", 9)
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

Hope it helps
 
O

oli merge

Hi, thanks to both answers, they look like the sort of thing i need to do. i
will try them out (and another answer i got on another forum) and get back to
you if I have any problems.

thanks again...
 
O

oli merge

Hello Brian, I have just tried out your code and it works a treat!

Thanks very much, my life should be a bit easier now.
 
B

Brian

Glad I could help, but I can't take the credit for the code. Found it when I
had the same problem earlier in the year.

regards,
 

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