Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to create a Macro in MS Word 2003 to resize all images in document

Posted on 2010-11-19
5
Medium Priority
?
552 Views
Last Modified: 2012-05-10
I run a merged fields document every week, this contains a picture on each page and there is 1 picture per page.  All of these pictures come through as different sizes.

I have previously asked people on EE to look at how we can re-code the document to pull through the images the correct size but due to the way the document was developed and how we run the merge this is not possible.

I was wondering as a workaround if something else could be done to resize all images simply rather than manually changing them all.

After a few google searches it appears that a Macro would resolve the problem, however, I have never created a Macro before.

I have found some sample code here:

http://en.allexperts.com/q/Microsoft-Word-1058/Word-resize-pictures.htm

But have no idea how to create a macro, add the code then run it.

Any help on this issue will be greatly appreciated.

Im have not added the document to this post as it contains personal customer data.  If this becomes necessary then i'll work through it and remove all the info.
0
Comment
Question by:auraorange
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 2

Author Comment

by:auraorange
ID: 34172581
If at all possible, I'd like to specify the size of the images in pixels
0
 
LVL 14

Accepted Solution

by:
Muhammad Ahmad Imran earned 2000 total points
ID: 34172596

Sub ResizeAllImages()
' make all images (both inline and floating)
' 11 cm wide while preserving aspect ratio

Dim oShp As Shape
Dim oILShp As InlineShape

For Each oShp In ActiveDocument.Shapes
With oShp
.Height = AspectHt(.Width, .Height, _
CentimetersToPoints(11))
.Width = CentimetersToPoints(11)
End With
Next

For Each oILShp In ActiveDocument.InlineShapes
With oILShp
.Height = AspectHt(.Width, .Height, _
CentimetersToPoints(11))
.Width = CentimetersToPoints(11)
End With
Next
End Sub

Private Function AspectHt( _
origWd As Long, origHt As Long, _
newWd As Long) As Long
If origWd <> 0 Then
AspectHt = (CSng(origHt) / CSng(origWd)) * newWd
Else
AspectHt = 0
End If
End Function

Open in new window

0
 
LVL 2

Author Comment

by:auraorange
ID: 34172976
Thank you the code is perfect!

I've changed the size perameters and that worked fine.

I still have a problem where the document also contains frames and text boxes and these have also resized but Ill have to probably post a new question for that
0
 
LVL 14

Expert Comment

by:Muhammad Ahmad Imran
ID: 34173023
Better you do that as it is against the policy of EE to ask multiple questions in one thread.

LeoAhmad
0
 
LVL 2

Author Closing Comment

by:auraorange
ID: 34173173
Worked perfectly

Thank you once again
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you work with Word a lot, you probably use styles. If you use styles a lot, you've probably balled your fist more often than not when working with the ribbon. In Word 2007/2010, one of the things that I find missing when using styles is a quic…
This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
This video teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question