Hi Marc,
In addition to the code Jay gave you, if the existing images were inserted
as linked images, then getting source filename is fairly straightforward.
For example:
Sub GetPicNames()
Dim i As Integer
Dim j As Integer
Dim PicName As String
With ActiveDocument
For i = 1 To .InlineShapes.Count
If Not .InlineShapes(i).LinkFormat Is Nothing Then
PicName = .InlineShapes(i).LinkFormat.SourceName
.InlineShapes(i).Range.InsertAfter (PicName)
End If
Next
For j = 1 To .Shapes.Count
If Not .Shapes(j).LinkFormat Is Nothing Then
PicName = .Shapes(j).LinkFormat.SourceName
.Shapes(j).Anchor.InsertAfter (PicName)
End If
Next
End With
End Sub
Cheers
"Marc C" wrote in message
...
Thank you very much for that Jay.
I got it to work - and now I want to ask if you could help me tweak it?
Is it possible to make 3 enhancements to the macro:
- only insert the file name into Word (as opposed to the file name and the
folder reference)
- add the file name to multiple images that I select for inserting into
the
document (currently, if I select multiple images, it only brings the file
reference of the first image selected in the group)
- when inserting the images, is it possible to control the size (height &
width) of the images - could default to say 1.5cm x 1.5cm. If this needs
to
be a separate macro - no problem.
You are helping me more than you know - thanks in anticipation.
Regards
Marc
"Jay Freedman" wrote:
Hi Marc,
There's nothing built-in to do that, but a macro would be easy.
You haven't given much detail about how you want this formatted, so
this macro should be considered just a first draft that you can tweak
to get what you want. See http://www.gmayor.com/installing_macro.htm
if needed.
Sub InsertPictureAndFileName()
Dim FileName As String
Dim dlg As Dialog
Set dlg = Dialogs(wdDialogInsertPicture)
If dlg.Show = -1 Then
FileName = dlg.Name
End If
If FileName = "" Then Exit Sub ' canceled
Selection.InsertAfter vbCr & FileName
Selection.Collapse wdCollapseEnd
End Sub
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
On Wed, 3 May 2006 17:08:02 -0700, Marc C
wrote:
I need to insert a number of image files into Word, and for each image,
I
need the file name to display below the image. Any ideas?
Cheers
Marc