Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-11-2014, 02:01 AM
lenguyenleduong lenguyenleduong is offline Insert and resize image Windows 7 32bit Insert and resize image Office 2010 32bit
Novice
Insert and resize image
 
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
  #2  
Old 05-11-2014, 05:31 AM
gmaxey gmaxey is offline Insert and resize image Windows 7 32bit Insert and resize image Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,421
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

This is because your code inserts the picture twice. Try:

Code:
With Application.Dialogs(wdDialogInsertPicture)
  If .Display = -1 Then
    If .Name <> "" Then
      Set Photo = ActiveDocument.InlineShapes.AddPicture(FileName:=.Name, _
                 LinkToFile:=False, SaveWithDocument:=True, _
                 Range:=Selection.Range)
    End If
  End If
End With
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 05-11-2014, 07:23 AM
lenguyenleduong lenguyenleduong is offline Insert and resize image Windows 7 32bit Insert and resize image Office 2010 32bit
Novice
Insert and resize image
 
Join Date: May 2014
Posts: 2
lenguyenleduong is on a distinguished road
Default

Quote:
Originally Posted by gmaxey View Post
This is because your code inserts the picture twice. Try:

Code:
With Application.Dialogs(wdDialogInsertPicture)
  If .Display = -1 Then
    If .Name <> "" Then
      Set Photo = ActiveDocument.InlineShapes.AddPicture(FileName:=.Name, _
                 LinkToFile:=False, SaveWithDocument:=True, _
                 Range:=Selection.Range)
    End If
  End If
End With
Thanks so much.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Shortcut for image resize Hatthans PowerPoint 0 01-06-2014 04:32 PM
How to resize the image in the header so that it fits the page Isadora Excel 1 08-20-2013 06:02 AM
Image proportional resize not functioning! alexfcm PowerPoint 0 09-27-2012 07:22 AM
Background image vs. insert image lilaria PowerPoint 0 04-18-2011 08:45 AM
Insert and resize image Insert Vector Image icu222much Office 2 11-07-2009 02:49 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:34 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft