View Single Post
 
Old 07-04-2017, 03:41 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,144
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

The following will replace a selected inline image with the named image and set the image width to the same size as the original, which for similar aspect ratio pictures means the same size:

Code:
Dim oRng As Range
Dim oShp As InlineShape
Dim lngWidth As Long
    Set oRng = Selection.InlineShapes(1).Range
    lngWidth = Selection.InlineShapes(1).Width
    oRng.Text = ""
    Set oShp = oRng.InlineShapes.AddPicture("C:\Path\Filename.jpg")
    oShp.LockAspectRatio = msoTrue
    oShp.Width = lngWidth
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote