Whenever I need to walk through a wizard I make screenshots of the steps. This comes in handy when someone else needs to do the same thing or just for logging purpose. The screenshots come in a Word document. To resize these images to minimize the number of pages I use this macro:
Sub ResizeImage() ' ' ResizeImage Macro ' Selected image(s) are resized to 5 cm in width ' Dim shape As InlineShape ' iterate all selected shapes For Each shape In Selection.InlineShapes ' remain aspect ratio shape.LockAspectRatio = msoTrue ' set with to 5 cm shape.Width = CentimetersToPoints(5) Next End Sub
Every Image selected (CTRL+A) will be resized to 5cm with aspect ratio locked. I pinned the macro to the Word Quick Access Toolbar for easy access.
Requested code by Nano07 with al little help from Graham Mayor
Sub ResizeImage() ' ' ResizeImage Macro 2 ' Selected image(s) are scaled to 100% and moved behind text in top left corner of the page ' Dim shape As InlineShape Dim shapeRange As shapeRange ' iterate all selected shapes For Each shape In Selection.InlineShapes ' remain aspect ratio shape.LockAspectRatio = msoTrue ' set with to 100 % shape.ScaleWidth = 100 ' convert to shape to get a shaperange shape.ConvertToShape Set shapeRange = Selection.shapeRange ' position relative to the page shapeRange.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage shapeRange.RelativeVerticalPosition = wdRelativeVerticalPositionPage ' anchor to 0.0 shapeRange.Top = 0 shapeRange.Left = 0 ' set to behind text shapeRange.WrapFormat.Type = wdWrapBehind Next End Sub
Hey Eric,
Thanks for the tip. I was wondering if this macro can be slightly modified to add the following: Align the image to the top left corner of the page.
My situation is that I have 8.5×11″ images that I use as backgrounds in the header section. BUT when I insert them in Word, the are imported at 71% of the original size. So what I’m manually doing is 1) putting the image “Behind text”, then resizing to 100% and then setting absolute postion to 0,0cm (top left corner of the page).
Can this macro be modified to do that?
Thanks man!
I’ve added the macro to the post.
Thanks so much for the macro! I know this is a super old post, but I was wondering if you could extend your original macro by having it also add a caption after each photo and have it increase numerically, ie Picture 1 [Add description], next photo would have Picture 2 [Add description] and so on. Or would it be simpler to insert a new paragraph after each photo? I had tried to add “Selection.InsertParagraphAfter” and “Selection.Move” right before the “Next” to no avail.
Thank you!
Hi thanks for the code.
I tried using it but found that the aspect ratio was not kept, i.e. adjustment only on the width. Would you be able to figure out why? I am using Words 2007. The object I have is an image and I just need to paste it into the page and resize them.
Thanks!
I’m unable to reproduce your issue. It sounds like the LockAspectRatio setting is lost. Could you check that the LockAspectRatio is set to msoTrue?
shape.LockAspectRatio = msoTrue
The original (first) macro dosnt work in word 2016 mac – do you know anything about this issue? Dim shape As InlineShape and For each… lines are red in the editor and running issues: “Compilation Error; syntax error”
Is was unaware of Microsoft porting Visual Basic to the Mac. Just tried it and no errors. Did you include the
Sub ResizeImage()
?Newer mind the previous – didt work when copy-pasted. Works rewritten into the editor.
No worries. Thanks for reporting back.
Hello Eric
I like your macro, but i was wondering if you could write it a bit differently, so the the picture-size gets changed depending on the current one.
For example that if the Picture has size “X” and you run the Macro once, it will become 20% smaller to size “Y”. And then that if you run the Macro again, it shrinks from size “Y” again for 20% instead of becoming the 20% smaller version of “X” again or even the original Picture-Size
My idea was to make two macros (including keyboard shortcuts), one to increase and one to decrease the size of a given picture by let’s say 10 percent or something so you could quickly change the size by pressing these shortcuts
I’ve tried the “included” keyboard-shordcut, that everyone in every single forum ever seems to reccomend (shift + Arrow Keys) but in my Case it just deselects the pictures.
Regards,
Sven
Change the original code and multiply the image Width with 0.80 (reduce 20%) or 1.20 (enlarge 20%)
Wow that reply was blazing fast!
Thanks alot my man!
Hi Eric,
I’m hoping you can be of help. The macro provided works perfectly, thank you. But I have been desperately hunting for the code for a single macro that both inserts an image and resizes it. Do you know of a solution?
Thank you,
Sara
The macro is not used for inserting images. What would inserting an image look like?
Hi Eric,
I’m hoping that you are still running this thread! I need to crop pictures to aspect ratio of Landscape 5:3, with width 4.5cm (and therefore height is 2.7cm). Are able to help at all? I am totally new to macros and am trying to record one, but I can’t work out to access the picture format tab as I can’t actually select the picture once recording has started.
Thank you
What version of MS Word are you using?
I have Word 2016.
You should first select the image and then start recording the macro. The tab will be available and you can resize the image.
I tried that, but when clicking ‘record macro’ I have to enter the name details, save as button or keyboard shortcut. As soon as I ok that dialog box, the picture becomes deselected and the picture format menu is no longer available
I had the same problem when reproducing. Please try the following:
Pause the recording, select the image again, resume recording.
Hello, I am trying to create a template for Biographies for our company. I created a mail merge document – easy peasy. HOWEVER. I need to insert a picture into EACH document (separate from the mail merge {unless it CAN be done via mail merge without modifying the report it’s being pulled from}). Before I merge the document – it’s no big deal to right click the picture and change it… but obviously that feature doesn’t work once the document is merged. I need to either 1. insert an image placeholder that is editable after the merge (right click and choose the correct photo file and be resized to the appropriate dimensions) or 2. pull the image file from a specified folder that matches the name on the bio (this I feel is impossible) or 3. something else that works??
Any assistance is greatly appreciated. I am using MS Word 2016
Hi, I have this code that assigns a image to a bookmark but I can’t figure out how to resize that image, can you help me?
Selection.GoTo What:=wdGoToBookmark, Name:=”Score”
Selection.InlineShapes.AddPicture FileName:=”D:\A+_Grade.png”, LinkToFile:=False, _
SaveWithDocument:=True
dear
can you also do it that it does all pictures in the document?
Just expand the selection at line 8 to all the images in the document. Simply remove the “Selection”: