View Single Post
 
Old 11-04-2017, 01:27 AM
FionaMcKenzie FionaMcKenzie is offline Windows 10 Office 2016
Novice
 
Join Date: Oct 2017
Location: Surrey, United Kingdom
Posts: 14
FionaMcKenzie is on a distinguished road
Default

Hi there,

I hope I have understood your question? Does the following code do what you want?

Option Explicit

Public Sub HyperlinkedPicture()

Dim oInlineShape As Word.InlineShape
Dim sFileFullName As String
Dim oFileBrowse As FileDialog

Set oFileBrowse = Application.FileDialog(msoFileDialogFilePicker)

With oFileBrowse
.Title = "Insert Picture"
.AllowMultiSelect = False
.ButtonName = "Insert and Hyperlink"
.Filters.Clear
.Filters.Add "Pictures", "*.jpg, *.jpeg, *.wmf, *.emf, *.gif"
If .Show Then

sFileFullName = .SelectedItems(1)

Set oInlineShape = Selection.InlineShapes.AddPicture _
(FileName:=sFileFullName, LinkToFile:=True, SaveWithDocument:=False)

ActiveDocument.Hyperlinks.Add Anchor:=oInlineShape.Range, _
Address:=sFileFullName

End If

End With

Set oInlineShape = Nothing
Set oFileBrowse = Nothing

End Sub
Reply With Quote