includepicture

S

Saj

Hi guys, I have an issue where as I am importing picture data which is not in
any standard size, i wish this size to be standard in the template. I have a
command in my document useing the following {includepicture "c://pics/1.jpg"}
i need this a subsequet picture to all be the same size - note graphic name
supplied is changed per record.

thanks
 
P

Peter Jamieson

It seems to be fairly easy to ensure that pictures are always reduced to a
certain size (e.g. the INCLUDEPICTURE field in an old-style Word Frame that
is the maximum size you want, then merge to a new document, then select the
document using control-A, then update the images using F9. You probably need
to remove any \*MERGEFORMAT switch in the INCLUDEPICTURE field.

However, that does not increase the size of pictures that are smaller than
the frame. To make all the pictures the same size,
a. you do not need the Frame
b. merge to a new document then run the following macro.

Sub adjustpictures()
Dim objShape As Word.InlineShape
Dim intWidth As Integer
DIm intHeight As Integer
' Set these to the values you want
intWidth = 100
intHeight = 60
ActiveDocument.Fields.Update
For Each objShape In ActiveDocument.InlineShapes
objShape.Width = intWidth
objShape.Height = intHeight
Next
End Sub

Unfortunately, that will distort any image whose sides are not in the ratio
100:60 so you could try the following to pick up the existing ratio for each
image:

Sub adjustpictures()
Dim objShape As Word.InlineShape
Dim dblSourceWidth As Double
Dim dblSourceHeight As Double
Dim dblTargetWidth As Double
Dim dblTargetHeight As Double
Dim dblWidthRatio As Double
Dim dblHeightRatio As Double
' Set these to the maximum values you want
dblTargetWidth = 100
dblTargetHeight = 60
ActiveDocument.Fields.Update
For Each objShape In ActiveDocument.InlineShapes
dblSourceWidth = objShape.Width
dblWidthRatio = dblSourceWidth / dblTargetWidth
dblSourceHeight = objShape.Height
dblHeightRatio = dblSourceHeight / dblTargetHeight
If dblWidthRatio > dblHeightRatio Then
objShape.Width = CInt(dblTargetWidth)
objShape.Height = CInt(dblTargetWidth * (dblSourceHeight /
dblSourceWidth))
Else
objShape.Height = CInt(dblTargetHeight)
objShape.Width = CInt(dblTargetHeight * (dblSourceWidth /
dblSourceHeight))
End If
Next
End Sub

Peter Jamieson
 

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