want to crop every image in the word document till end

P

programer

How do i have a macro which crops every picture it encounters throughou
the end of the word document
I tried recording a macro ,this was the code i got.

Sub CropImageMacro(

' CropImageMacro Macr
' This Macro Crops unwanted parts of an imag


Selection.MoveDown Unit:=wdLine, Count:=
Selection.MoveRight Unit:=wdCharacter, Count:=20, Extend:=wdExten
Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExten
Selection.Delete Unit:=wdCharacter, Count:=

Application.Templates.LoadBuildingBlock
Dim sngHeight, sngWidth, sngCropTop, sngCropBottom As Singl
sngCropTop = 0.15
sngCropBottom = 0.0

With ActiveDocument.InlineShapes(1

sngHeight = .Heigh
sngWidth = .Widt
With .PictureForma

.CropTop = sngHeight * sngCropTo

.CropBottom = sngHeight * sngCropBotto
End Wit
.Height = .Heigh

.Width = .Widt
End Wit

sngCropTop = 0.01
sngCropBottom = 0.06

With ActiveDocument.InlineShapes(2

sngHeight = .Heigh
sngWidth = .Widt
With .PictureForma

.CropTop = sngHeight * sngCropTo

.CropBottom = sngHeight * sngCropBotto
End Wit
.Height = .Heigh

.Width = .Widt
End Wit

With ActiveDocument.InlineShapes(3

sngHeight = .Heigh
sngWidth = .Widt
With .PictureForma

.CropTop = sngHeight * sngCropTo

.CropBottom = sngHeight * sngCropBotto
End Wit
.Height = .Heigh

.Width = .Widt
End Wit

With ActiveDocument.InlineShapes(4

sngHeight = .Heigh
sngWidth = .Widt
With .PictureForma

.CropTop = sngHeight * sngCropTo

.CropBottom = sngHeight * sngCropBotto
End Wit
.Height = .Heigh

.Width = .Widt
End Wit

With ActiveDocument.InlineShapes(5

sngHeight = .Heigh
sngWidth = .Widt
With .PictureForma

.CropTop = sngHeight * sngCropTo

.CropBottom = sngHeight * sngCropBotto
End Wit
.Height = .Heigh

.Width = .Widt
End Wit

With ActiveDocument.InlineShapes(6

sngHeight = .Heigh
sngWidth = .Widt
With .PictureForma

.CropTop = sngHeight * sngCropTo

.CropBottom = sngHeight * sngCropBotto
End Wit
.Height = .Heigh

.Width = .Widt
End Wit

With ActiveDocument.InlineShapes(7

sngHeight = .Heigh
sngWidth = .Widt
With .PictureForma

.CropTop = sngHeight * sngCropTo

.CropBottom = sngHeight * sngCropBotto
End Wit
.Height = .Heigh

.Width = .Widt
End Wit
End Su

The current macro I have only crops images upto 8 pages. It also give
a run command error if it encounters only 7 pages in the document .
want it to not freak out and give erro
messages if ever it does encounter less than 8 pages, and neither do
want it to stop doing its job if it encounters more than 8 pages
 

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