View Single Post
 
Old 05-20-2018, 12:38 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,106
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 of
Default

The following macro will insert a linked thumbnail image at the cursor, subject to the provisos mentioned by Andrew. Call it from a macro that provides the image path and optionally the screen tip text.



Code:
Sub InsThumbNail(strPath As String, _
                 Optional strTipText As String = "Link to full size image")
'Graham Mayor - http://www.gmayor.com - Last updated - 20 May 2018
Dim oShape As InlineShape
    Set oShape = Selection.InlineShapes.AddPicture(FileName:=strPath, _
                                                   LinkToFile:=False, _
                                                   SaveWithDocument:=True)
    With oShape
        .LockAspectRatio = msoTrue
        .Width = InchesToPoints(1)
        ActiveDocument.Hyperlinks.Add Anchor:=.Range, _
                                      Address:=strPath, _
                                      SubAddress:="", _
                                      ScreenTip:=strTipText, _
                                      TextToDisplay:=.Range.Text
    End With
lbl_Exit:
    Set oShape = Nothing
    Exit Sub
End Sub
__________________
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