I have a weird case in a word automation program I’m developing using the Office Interop and C# 3.5
One task of the program is to copy any linked images in the word document to a different location and rewrite the Linked Source of those images to the new location.
Now, in one document, when I check the linked files (using Word 2010), it points an image to a location similar to images\image_file.jpg – So, the image is in a subfolder of the folder where the document is. That’s totally correct.

But, when my program runs into that image, the LinkFormat.SourceFullName of that same image gives me a path on our local network, e.g. \\net-storage\customer\001 - customername\data\images\documents\image_file.jpg, without any correlation whatsoever to the actual image link I’m expecting.
What’s going wrong here? How do I get the correct image source in my program?
Edit to sw_lasse: I’m sure this is a relative path, because (in other documents) after deleting the image in the relative path and updating the fields in word, the image is not found. So it’s definitely a relative path.
Also, the two paths (network and relative) have no correlation to each other. The images on the network use a completely different folder hierarchy, so that’s why there’s a document subfolder, while it doesn’t exist in the relative path.
I know your writing VSTO C# code and this is VBA, but I believe this explains the odd behaviour your seeing.
You cannot use:
… because if the user has inserted a picture from a different folder, the Default File Path returns that folder rather than the actual setting from the dialog box. Instead, you can use:
Similarly, you cannot use:
to get the default document path, because this returns the current FileOpen path, not the default documents path!!
Instead, use:
These days I’m pretty good at converting VBA to C#, if you provide some code that doesn’t work I’ll convert this VBA to suit.
Ref: How to retrieve Word’s default Documents path or Pictures path setting