![]() |
|
#1
|
|||
|
|||
|
So I have this very large document with multiple images that need to be resized to fit within the margins I have set. As you can imagine going through them one by one will be very time-consuming, boring and a little frustrating.
I was wondering if there was a way to write a macro that could do that for me in one click? Thank you for any help offered. |
|
#2
|
||||
|
||||
|
How are the images inserted (wrapping option). Do you want to make them larger or smaller? What is the width between the margins in question? Are they all in the body of the document?
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
#3
|
|||
|
|||
|
The images are inserted between the text. The text being above and below. They need to be reduced as currently they are outside the margins of the document. They just need to fit inside the document, no indents or spacing applied to them.
|
|
#4
|
||||
|
||||
|
You could use a macro like:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim Sctn As Section, iShp As InlineShape, Shp As Shape, sWdth As Single, sHght As Single
For Each Sctn In ActiveDocument.Sections
With Sctn
With .PageSetup
sWdth = .PageWidth - .LeftMargin - .RightMargin - .Gutter
sHght = .PageHeight - .TopMargin - .BottomMargin
End With
For Each iShp In .Range.InlineShapes
With iShp
.LockAspectRatio = True
If .Width > sWdth Then .Width = sWdth
If .Height > sHght Then .Height = sHght
End With
Next
For Each Shp In .Range.ShapeRange
With Shp
.LockAspectRatio = True
If .Width > sWdth Then .Width = sWdth
If .Height > sHght Then .Height = sHght
End With
Next
End With
Next
Application.ScreenUpdating = True
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
| Tags |
| images, macro, macros |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Opening all selected images, resizing images and placing them into a table.
|
John Livewire | Word VBA | 1 | 09-15-2017 11:24 PM |
| Automatic resizing of images | seanspotatobusiness | Forum Support | 1 | 03-02-2017 07:44 PM |
| Please help! Why do images and shapes disappear when resizing or moving? | 0-lara-o | Word | 0 | 10-26-2016 08:45 PM |
Insert multiple images & controls into a document
|
vanwijnen | Word VBA | 1 | 06-05-2015 06:16 AM |
Resizing all images in document
|
ShSimpson | Drawing and Graphics | 1 | 05-10-2012 01:03 AM |