Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2006

Tip: Looking for answers? Try searching our database.

Efficient way to change ALL links to a new source?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
dochoa - 10 Jan 2006 15:17 GMT
Every year, updates are made to an Excel file. This file in turn will serve
as a source for a related document containing many links.
Currently, to change the source of the links within the document, we are
choosing Edit>Links>(selecting all links)>Change Source. This means that we
have to choose the new source file for every link within the document.
Is there any easier way to perform this update every year?
Doug Robbins - Word MVP - 10 Jan 2006 21:27 GMT
Use the following macro:

' Macro created 26/10/01 by Doug Robbins to update links in a document
'
Dim alink As Field, linktype As Range, linkfile As Range
Dim linklocation As Range, i As Integer, j As Integer, linkcode As Range
Dim Message, Title, Default, Newfile
Dim counter As Integer

counter = 0
For Each alink In ActiveDocument.Fields
   If alink.Type = wdFieldLink Then
       Set linkcode = alink.Code
       i = InStr(linkcode, Chr(34))
       Set linktype = alink.Code
       linktype.End = linktype.Start + i
       j = InStr(Mid(linkcode, i + 1), Chr(34))
       Set linklocation = alink.Code
       linklocation.Start = linklocation.Start + i + j - 1
       If counter = 0 Then
           Set linkfile = alink.Code
           linkfile.End = linkfile.Start + i + j - 1
           linkfile.Start = linkfile.Start + i
           Message = "Enter the modified path and filename following this
Format " & linkfile
           Title = "Update Link"
           Default = linkfile
           Newfile = InputBox(Message, Title, Default)
       End If
       linkcode.Text = linktype & Newfile & linklocation
       counter = counter + 1
   End If
Next alink

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> Every year, updates are made to an Excel file. This file in turn will
> serve
[quoted text clipped - 4 lines]
> have to choose the new source file for every link within the document.
> Is there any easier way to perform this update every year?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.