Forum Discussion
How to know the original path of an inserted image ?
Hi, sorry I completely missed you answer last year (I used my personal acount and I almost never go check my mails there and as I was in a hurry and found a workaround I never came back here either).
I found another solution where I needed to basically open the Excel file as a text file (but first I had to access it with 7zip or something like that) and then I could see the links. I'm sorry I don't remember the exact procedure and I don't think I kept the link (because sometimes I'm so stupid...).
Your macro won't help me in this case but I appreciate anyway.
You rote :
- Linked Images: If you plan to move workbooks and need to retain image paths, consider linking images rather than embedding them. Linked images retain their file paths and can be updated if the paths remain valid on the new system. However, linked images require that the path remains accessible and unchanged.
My problem is here at the beginning, when I insert an image in a cell using "Insert > Image > inside cell > from this computer" it creates a linked image automatically (but at the time I didn't know that) so when I changed my laptop and moved my files (or shared the Excel file with someone else) I had a problem with the linked images.
However I don't know how to change the behaviour of Excel so that when I insert an image from my computer it creates an embedded image instead of a linked image. In my case I need that because I need to send the Excel file to other people and I don't want to send a full ZIP file with the images contained in the Excel file.
I can't believe that Microsoft didn't do a smart function to :
1- Better manage linked images and update them
2- Know where the images comes from when the link is broken.
When you use Insert > Picture > From This Device > Insert in Cell in Excel:
- Excel sometimes embeds images, but
- often, it links them if you insert the image as a "linked image", or depending on the method used in the underlying API.
- The problem is: Excel does not make it obvious whether the image is embedded or linked.
- And yes — Microsoft has no proper UI to manage image links, unlike how it manages formula links (Data > Edit Links for formulas but not for images!).
About your discovery: extracting with 7-Zip
You were absolutely right! Excel .xlsx files are actually ZIP archives internally.
If you:
- Change the file extension from .xlsx to .zip OR
- Open with 7-Zip, WinRAR, or similar,
You will find this structure inside:
/xl/
/media/ <-- embedded images are here
/drawings/ <-- links to images are managed here
/worksheets/ <-- drawings are attached to sheets
If your images were embedded, you would see them in /xl/media/ as files like image1.png, image2.jpeg, etc.
If your images were linked, you would find the link path written in XML files like:
- xl/drawings/_rels/drawing1.xml.rels
- and in xl/drawings/drawing1.xml
- or even in xl/worksheets/_rels/sheet1.xml.rels.
There you could read the original absolute file paths you used on your old computer (like C:\Users\you\Pictures\mychart.png).
That's how you can recover the original image paths.
How to make Excel embed images instead of linking
Sadly, Excel itself does not give you a checkbox like "embed or link" when inserting a picture.
BUT here’s what you can do to force embedding:
Method | Behavior | How to Ensure Embedding |
Insert via UI (Insert > Pictures > This Device) | Depends | Immediately after inserting, copy the picture (Ctrl+C) and paste it again (Ctrl+V). The pasted image becomes embedded. |
Insert via VBA | Full Control | If you use VBA Shapes.AddPicture, you can set LinkToFile:=False, so it embeds. |
Copy-Paste from another app (e.g., Paint) | Always Embedded | Copy from outside Excel (like Paint) and paste. |
So, if you want guaranteed embedded images without VBA, an easy trick is:
- Insert normally
- Immediately copy the inserted image (Ctrl+C)
- Paste it again (Ctrl+V)
- Delete the original
- The pasted version is now embedded.
It’s stupid simple… but it works.
Short VBA Trick to Embed All Linked Images
If you already have many linked images, you can automatically re-embed them with VBA:
Sub ListLinkedImages()
Dim ws As Worksheet
Dim shp As Shape
Dim reportWs As Worksheet
Dim reportRow As Long
On Error Resume Next
Set reportWs = ThisWorkbook.Worksheets("Image Links Report")
If reportWs Is Nothing Then
Set reportWs = ThisWorkbook.Worksheets.Add
reportWs.Name = "Image Links Report"
Else
reportWs.Cells.Clear
End If
On Error GoTo 0
reportWs.Cells(1, 1).Value = "Sheet Name"
reportWs.Cells(1, 2).Value = "Image Name"
reportWs.Cells(1, 3).Value = "Linked File Path"
reportRow = 2
For Each ws In ThisWorkbook.Worksheets
For Each shp In ws.Shapes
If shp.Type = msoLinkedPicture Then
reportWs.Cells(reportRow, 1).Value = ws.Name
reportWs.Cells(reportRow, 2).Value = shp.Name
reportWs.Cells(reportRow, 3).Value = shp.LinkFormat.SourceFullName
reportRow = reportRow + 1
End If
Next shp
Next ws
MsgBox "Done! Found " & reportRow - 2 & " linked images.", vbInformation
End Sub
'Code is Untestet, backup your file first.- It copies every linked picture,
- Pastes it back (as embedded),
- Deletes the original linked one.
Super useful before sending your file to others!
Final thoughts
- Microsoft really should have given us better image management tools.
- You found the "archive and search the XML" trick, which is the real hardcore way.
- If you're rebuilding your reports for portability, I recommend embedding images before you send or backup the file. Hope it helps 🙂