View Single Post
 
Old 05-11-2014, 02:01 AM
lenguyenleduong lenguyenleduong is offline Windows 7 32bit Office 2010 32bit
Novice
 
Join Date: May 2014
Posts: 2
lenguyenleduong is on a distinguished road
Default Insert and resize image

Dear friends,

I create a word macro to insert, crop and resize image. But it duplicate the inserted image, one orginal size and one resized. How to solve this? Thanks.
Here is the code

Private Sub CommandButton1_Click()

Dim Photo As InlineShape
Dim sngHeight, sngWidth, sngCrop As Single
Dim strPicName As String

strPicName = ""

With Application.Dialogs(wdDialogInsertPicture)
If .Show = -1 Then strPicName = .Name
End With


Set Photo = ActiveDocument.InlineShapes.AddPicture(FileName:=s trPicName, _
LinkToFile:=False, SaveWithDocument:=True)

With Photo
sngHeight = .Height
sngWidth = .Width
With .PictureFormat
.CropLeft = sngWidth * 0.175
.CropRight = sngWidth * 0.12
'.CropTop = sngHeight * sngCrop
'.CropBottom = sngHeight * sngCrop
End With
'.Height = .Height * 1 / (1 - sngCrop * 2)
'.Width = .Width * 1 / (1 - sngCrop * 2)
.LockAspectRatio = msoCTrue

.Width = .Width - (CropRight + CropLeft)
.Width = InchesToPoints(1.5)

End With

End Sub
Reply With Quote