Reply
 
Thread Tools Display Modes
  #1   Report Post  
programer programer is offline
Junior Member
 
Posts: 0
Default want to crop every image in the word document till end

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

Sub CropImageMacro()
'
' CropImageMacro Macro
' This Macro Crops unwanted parts of an image
'

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


Application.Templates.LoadBuildingBlocks
Dim sngHeight, sngWidth, sngCropTop, sngCropBottom As Single
sngCropTop = 0.154
sngCropBottom = 0.05


With ActiveDocument.InlineShapes(1)

sngHeight = .Height
sngWidth = .Width
With .PictureFormat

.CropTop = sngHeight * sngCropTop

.CropBottom = sngHeight * sngCropBottom
End With
.Height = .Height

.Width = .Width
End With

sngCropTop = 0.014
sngCropBottom = 0.069


With ActiveDocument.InlineShapes(2)

sngHeight = .Height
sngWidth = .Width
With .PictureFormat

.CropTop = sngHeight * sngCropTop

.CropBottom = sngHeight * sngCropBottom
End With
.Height = .Height

.Width = .Width
End With

With ActiveDocument.InlineShapes(3)

sngHeight = .Height
sngWidth = .Width
With .PictureFormat

.CropTop = sngHeight * sngCropTop

.CropBottom = sngHeight * sngCropBottom
End With
.Height = .Height

.Width = .Width
End With

With ActiveDocument.InlineShapes(4)

sngHeight = .Height
sngWidth = .Width
With .PictureFormat

.CropTop = sngHeight * sngCropTop

.CropBottom = sngHeight * sngCropBottom
End With
.Height = .Height

.Width = .Width
End With

With ActiveDocument.InlineShapes(5)

sngHeight = .Height
sngWidth = .Width
With .PictureFormat

.CropTop = sngHeight * sngCropTop

.CropBottom = sngHeight * sngCropBottom
End With
.Height = .Height

.Width = .Width
End With

With ActiveDocument.InlineShapes(6)

sngHeight = .Height
sngWidth = .Width
With .PictureFormat

.CropTop = sngHeight * sngCropTop

.CropBottom = sngHeight * sngCropBottom
End With
.Height = .Height

.Width = .Width
End With

With ActiveDocument.InlineShapes(7)

sngHeight = .Height
sngWidth = .Width
With .PictureFormat

.CropTop = sngHeight * sngCropTop

.CropBottom = sngHeight * sngCropBottom
End With
.Height = .Height

.Width = .Width
End With
End Sub


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

Last edited by programer : July 28th 13 at 07:18 AM
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Stefan Blom[_3_] Stefan Blom[_3_] is offline
external usenet poster
 
Posts: 6,897
Default want to crop every image in the word document till end

Note that traffic is slow in this newsgroup, nowadays. If you don't get (an
insightful) reply here, consider reposting the question in the Office
programming forum at Microsoft Community
(http://answers.microsoft.com/en-us/o...tomize?tab=QnA) or the
Word Developer forum at MSDN
(http://social.msdn.microsoft.com/For...forum=worddev).
Both of these forums require a Live ID (Microsoft ID) to log in.

--
Stefan Blom
Microsoft Word MVP




"programer" wrote in message
news

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

Sub CropImageMacro()
'
' CropImageMacro Macro
' This Macro Crops unwanted parts of an image
'

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


Application.Templates.LoadBuildingBlocks
Dim sngHeight, sngWidth, sngCropTop, sngCropBottom As Single
sngCropTop = 0.154
sngCropBottom = 0.05


With ActiveDocument.InlineShapes(1)

sngHeight = .Height
sngWidth = .Width
With .PictureFormat

.CropTop = sngHeight * sngCropTop

.CropBottom = sngHeight * sngCropBottom
End With
.Height = .Height

.Width = .Width
End With

sngCropTop = 0.014
sngCropBottom = 0.069


With ActiveDocument.InlineShapes(2)

sngHeight = .Height
sngWidth = .Width
With .PictureFormat

.CropTop = sngHeight * sngCropTop

.CropBottom = sngHeight * sngCropBottom
End With
.Height = .Height

.Width = .Width
End With

With ActiveDocument.InlineShapes(3)

sngHeight = .Height
sngWidth = .Width
With .PictureFormat

.CropTop = sngHeight * sngCropTop

.CropBottom = sngHeight * sngCropBottom
End With
.Height = .Height

.Width = .Width
End With

With ActiveDocument.InlineShapes(4)

sngHeight = .Height
sngWidth = .Width
With .PictureFormat

.CropTop = sngHeight * sngCropTop

.CropBottom = sngHeight * sngCropBottom
End With
.Height = .Height

.Width = .Width
End With

With ActiveDocument.InlineShapes(5)

sngHeight = .Height
sngWidth = .Width
With .PictureFormat

.CropTop = sngHeight * sngCropTop

.CropBottom = sngHeight * sngCropBottom
End With
.Height = .Height

.Width = .Width
End With

With ActiveDocument.InlineShapes(6)

sngHeight = .Height
sngWidth = .Width
With .PictureFormat

.CropTop = sngHeight * sngCropTop

.CropBottom = sngHeight * sngCropBottom
End With
.Height = .Height

.Width = .Width
End With

With ActiveDocument.InlineShapes(7)

sngHeight = .Height
sngWidth = .Width
With .PictureFormat

.CropTop = sngHeight * sngCropTop

.CropBottom = sngHeight * sngCropBottom
End With
.Height = .Height

.Width = .Width
End With
End Sub


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




--
programer


Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
when loading any document scrolls past till the end of the docume Pedro Microsoft Word Help 1 September 29th 08 10:06 PM
Från word till pdf Lotta Microsoft Word Help 2 May 19th 07 08:48 PM
how do I crop part of a scanned document IN word Uew Nuser Microsoft Word Help 3 December 3rd 06 02:58 PM
how i remove the page crop mark in a word document mathi Page Layout 1 October 19th 05 09:00 AM
When I open a word doc my screen gets lines in it till I can't rea buzzy Microsoft Word Help 1 August 28th 05 03:54 AM


All times are GMT +1. The time now is 11:47 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"