Home |
Search |
Today's Posts |
#1
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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 | |
|
|
Similar Threads | ||||
Thread | Forum | |||
when loading any document scrolls past till the end of the docume | Microsoft Word Help | |||
Från word till pdf | Microsoft Word Help | |||
how do I crop part of a scanned document IN word | Microsoft Word Help | |||
how i remove the page crop mark in a word document | Page Layout | |||
When I open a word doc my screen gets lines in it till I can't rea | Microsoft Word Help |