View Single Post
 
Old 05-19-2016, 09:15 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,142
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

If you copy an image from the browser the hyperlink doesn't normally come with it, so the error relates to there not being a hyperlink to delete. You can error trap that

Code:
Sub Macro1()
Dim oRng As Range
Dim oLink As Hyperlink
Dim oShape As InlineShape
    Set oRng = Selection.Range
    oRng.Paste
    For Each oLink In oRng.Hyperlinks 'If there is one
        oLink.Delete
    Next oLink
    For Each oShape In oRng.InlineShapes
        With oShape
            .Width = InchesToPoints(3) 'The width sets the size of the image with the same aspect ratio
        End With
    Next oShape
lbl_Exit:
    Set oRng = Nothing
    Set oLink = Nothing
    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