Doug Van
asked on
Word 2013 linked images need relative paths!
Hello all,
I am writing a document where all of the inserted images will be constantly updated. My solution was to insert the image with 'link to file'. So when an image was replaced in folder, F9 or restart Word to see the updated image.
It worked perfectly until I needed to move my document folder to another computer. The document folder structure remained the same BUT the root folder changed. Now, instead of images, I have broken links!
Word 2013 seems to insist on absolute folder locations. That is insane!
Please tell me how to attach an image with a relative folder location. Google search suggested an answer on 'windowsecrets' but the URL is broken.
Thank you much!
I am writing a document where all of the inserted images will be constantly updated. My solution was to insert the image with 'link to file'. So when an image was replaced in folder, F9 or restart Word to see the updated image.
It worked perfectly until I needed to move my document folder to another computer. The document folder structure remained the same BUT the root folder changed. Now, instead of images, I have broken links!
Word 2013 seems to insist on absolute folder locations. That is insane!
Please tell me how to attach an image with a relative folder location. Google search suggested an answer on 'windowsecrets' but the URL is broken.
Thank you much!
ASKER
Hello Graham,
Thank you. Unfortunately, it doesn't work.
I am getting a runtime error 91. Object variable or With block variable not set.
Also, how would I indicate a relative link in the strNewRoot variable?
All my images are in a sub folder 'images' inside the folder that contains the main document.
Thank you
Thank you. Unfortunately, it doesn't work.
I am getting a runtime error 91. Object variable or With block variable not set.
Also, how would I indicate a relative link in the strNewRoot variable?
All my images are in a sub folder 'images' inside the folder that contains the main document.
Thank you
Sorry, I thought that your document comprised linked pictures only. This new code checks the types of shapes and inline shapes
As far as I know, Microsoft don't support a way of using relative paths with Link fields. I do have some recollection of reading that it can be done by editing the XML, but I don't think that it will be straightforward if many pictures need treating. I'll try to recall where I saw the information and research from there.
Sub ChangePicturesRootfolder()
Dim ilsh As InlineShape
Dim sh As Shape
Dim strNewRoot As String
Dim strOldRoot As String
strOldRoot = "C:\MyOldPictures"
strNewRoot = "D:\MyNewPictures"
For Each ilsh In ActiveDocument.InlineShapes
If ilsh.Type = wdInlineShapeLinkedPicture Then
ilsh.LinkFormat.SourceFullName = Replace(ilsh.LinkFormat.SourceFullName, strOldRoot, strNewRoot)
End If
Next ilsh
For Each sh In ActiveDocument.Shapes
If sh.Type = msoLinkedPicture Then
sh.LinkFormat.SourceFullName = Replace(sh.LinkFormat.SourceFullName, strOldRoot, strNewRoot)
End If
Next sh
End Sub
As far as I know, Microsoft don't support a way of using relative paths with Link fields. I do have some recollection of reading that it can be done by editing the XML, but I don't think that it will be straightforward if many pictures need treating. I'll try to recall where I saw the information and research from there.
ASKER
Hello Graham,
>Sorry, I thought that your document comprised linked pictures only. This new code
>checks the types of shapes and inline shapes
Actually, I am only using linked images (nothing more) so this is rather odd.
>As far as I know, Microsoft don't support a way of using relative paths with Link fields.
I am trying to wrap my head around the reasoning for this. I wouldn't even have accepted this in the 80's!
I need to use linked images, due to the beta nature of the product I am documenting. But reviewers are seeing broken links when I transfer a zipped copy to them (includes the images folder).
...
So I took apart the docx format (what a mess under the hood!) and found the file I need to modify is: ...\word\_rels\document.xm l.rels
The question is how to edit the absolute paths and change them to relative paths?
Original:
Target="file:///C:\Users\u ser01\Docu ments\Quic k%20Start% 20Guide\im ages\0030_ Store_Bloc k_back.jpg "
Is this a valid relative path:
Target="file:images\0030_S tore_Block _back.jpg"
or is this valid:
Target="images\0030_Store_ Block_back .jpg"
They both seem to work but I haven't fully tested this yet.
Also, is any of the other stuff important to consider... example:
TargetMode="External"/><Re lationship Id="rId18"
I really wish I did not have to resort to this manual editing.
Thank you for your help.
>Sorry, I thought that your document comprised linked pictures only. This new code
>checks the types of shapes and inline shapes
Actually, I am only using linked images (nothing more) so this is rather odd.
>As far as I know, Microsoft don't support a way of using relative paths with Link fields.
I am trying to wrap my head around the reasoning for this. I wouldn't even have accepted this in the 80's!
I need to use linked images, due to the beta nature of the product I am documenting. But reviewers are seeing broken links when I transfer a zipped copy to them (includes the images folder).
...
So I took apart the docx format (what a mess under the hood!) and found the file I need to modify is: ...\word\_rels\document.xm
The question is how to edit the absolute paths and change them to relative paths?
Original:
Target="file:///C:\Users\u
Is this a valid relative path:
Target="file:images\0030_S
or is this valid:
Target="images\0030_Store_
They both seem to work but I haven't fully tested this yet.
Also, is any of the other stuff important to consider... example:
TargetMode="External"/><Re
I really wish I did not have to resort to this manual editing.
Thank you for your help.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Hello Graham,
Thank you for your assistance. Your effort was appreciated.
Thank you for your assistance. Your effort was appreciated.
ASKER
Hmm... this manual editing of "document.xml.rels" doesn't seem to fully work because reviewers are still reporting broken links.
I think the only viable solution is finding a way to do on-line collaboration that doesn't require Word and doesn't require SharePoint.
I think the only viable solution is finding a way to do on-line collaboration that doesn't require Word and doesn't require SharePoint.
Thanks for the further feedback.
That might be why Microsoft themselves don't support it any more.
That might be why Microsoft themselves don't support it any more.
ASKER
I just discovered, this morning, that the problem seems to be affecting Mac users only.
No matter what the problem is, it is ridiculous that Word only directly supports absolute paths! I would not have accepted this even 15 years ago!
No matter what the problem is, it is ridiculous that Word only directly supports absolute paths! I would not have accepted this even 15 years ago!
Open in new window