![]() |
|
|
|
#1
|
|||
|
|||
|
I have a word file that has images embedded. I want to add a caption below each image to show the filename. I know how to loop through the images and add a caption (code below) but how can I find the original file name please?
Code:
Option Explicit
Sub Example1()
Dim intCount As Integer
Dim i As Integer
For i = 1 To InlineShapes.Count
'check if the current shape is a picture
If InlineShapes.Item(i).Type = _
wdInlineShapePicture Then
'select the picture
InlineShapes.Item(i).Select
'assign a caption to it
Selection.InsertCaption Label:="Figure", _
Title:="WHERE DO I FIND THE FIENAME TO ADD?", _
Position:=wdCaptionPositionBelow
End If
Next i
End Sub
|
|
#2
|
||||
|
||||
|
There is nothing stored in a Word document that can tell you the original name of an embedded image; only the names of linked images can be retrieved.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#3
|
|||
|
|||
|
As I feared, what a damn shame, oh well I will have to do it manually then.
|
|
#4
|
|||
|
|||
|
I know it has been a couple of years since you ask this question, however I found this online posted which was actually posted 5 years ago which allows you to do exactly what you wanted to do. I was in the same boat so started Googling and found this thread first but kept looking and came across this video.
https://www.youtube.com/watch?v=crmEFyFcxac I think you might have to re-add the images but you can try first. Hope it works for you. |
|
#5
|
||||
|
||||
|
The topic discussed in this thread concerns the retrieval of filenames for images already embedded in the document, which is not possible. If you want to insert multiple images, there is a much more sophisticated approach in the Automate the Insertion of Multiple Images into a Document 'Sticky' thread at the top of the Drawing and Graphics forum: https://www.msofficeforums.com/drawi...-document.html
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#6
|
|||
|
|||
|
Thanks macropod.
|
|
| Tags |
| vba, word vba |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Insert multiple images in table with filename in column to the side
|
Kass | Word VBA | 2 | 05-03-2018 08:14 AM |
| Extract embedded images and save according to hyperlink. | PRA007 | Word VBA | 2 | 02-05-2016 01:46 AM |
How do i include embedded images in a mail-merge?
|
Hindmost | Mail Merge | 14 | 09-18-2015 02:01 PM |
| Source code for embedded images | whitland | Outlook | 0 | 09-06-2011 03:59 AM |
| simple way to save embedded images? | Newmarket2 | Drawing and Graphics | 0 | 03-12-2010 12:24 PM |