Automating a Hyperlink in a Picture

S

Strong Eagle

I created a macro that automatically adds a hyperlink based upon the
name of the picture being inserted. It works great as long the the
insertions are done sequentially down the page. However, if I insert a
picture between two previously inserted pictures, I lose the hyperlink.

It seems that I need to know how to obtain the current selection of
inlineshape as it must have been set by the insert picture routine but
I don't know how to get that information. Help appreciated.

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 2/27/2005 by Wayne Herbert
'
Dim PicDlg As Dialog
Dim i As Integer
Dim FName As String
Dim Shape1 As InlineShape
Set fs = CreateObject("Scripting.FileSystemObject")
Set PicDlg = Dialogs(wdDialogInsertPicture)
If PicDlg.Show = -1 Then
' get the index of last picture added and select it
i = ActiveDocument.InlineShapes.Count
ActiveDocument.InlineShapes.Item(i).Select
' extract the filename from full path
FName = fs.GetFileName(PicDlg.Name)
' set a hyperlink with name and selection
ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range,
Address:=FName, _
SubAddress:=""
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top