by Allen Wyatt
(last updated January 16, 2017)
Jennifer has a Word document that has links to hundreds of other documents. Now she wants to replace each of those links with the actual document referenced. (In other words, she wants to embed the referenced documents.) She wonders if there is a global way to do this instead of having to do each document separately.
The solution depends on how, exactly, you have the other documents linked to your current document. If you inserted the contents of another file using the Text from File command (Insert tab | Object | Text from File) and chose to insert as a link, then the file contents are actually added through the use of the INCLUDETEXT field. As with any other field, you can unlink the field in this manner:
If your documents are linked using hyperlinks, then the process is a bit more difficult. The reason is simple: a hyperlink is only a pointer to the other document, not the actual contents of that other document. This means that you need to come up with a way to open the other document, grab its contents, and stuff it into the current document in place of the hyperlink.
This type of work is perfect for a macro to do. The following example actually steps backwards through each hyperlink and inserts the files:
Sub InsertDocs() Dim aRange As Range Dim J As Long Set aRange = ActiveDocument.Range ' Go backwards because hyperlinks are deleted as processed For J = aRange.Hyperlinks.Count to 1 Step -1 With aRange.Hyperlinks(J) ' Process only hyperlinks to documents If InStr(.Address, ".doc") > 0 Then .Range.Select On Error GoTo noFile .Follow On Error GoTo 0 ActiveDocument.Range.Copy ActiveDocument.Close Selection.Paste End If GoTo nextFile noFile: On Error GoTo 0 MsgBox "Cannot open file " & .Address nextFile: End With Next J End Sub
Note that the macro checks the hyperlink to make sure it contains the letters ".doc". This doesn't mean that it is limited only to the old .DOC files, as the test would also match the letters ".docx" and ".docm".
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (6824) applies to Microsoft Word 2007, 2010, and 2013.
The First and Last Word on Word! Bestselling For Dummies author Dan Gookin puts his usual fun and friendly candor back to work to show you how to navigate Word 2013. Spend more time working and less time trying to figure it all out! Check out Word 2013 For Dummies today!
Convert those URLs into regular text! It's easy to do when you follow the steps in this tip.Discover More
Got some active links in your document? Do you want to have them activated when you click on them, or do you want to require ...Discover More
Want to add a small pop-up window over a word in your document? There is no way to do this directly in Word, but you can use ...Discover More
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.