A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » Tables
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Multiple Links from Word 2003 table to Excel 2003



 
 
Thread Tools Display Modes
  #1  
Old March 8th, 2008, 03:06 PM posted to microsoft.public.word.tables
Cyberjeff
external usenet poster
 
Posts: 2
Default Multiple Links from Word 2003 table to Excel 2003

Stating the version of my office package for the previous post:
I have a Word template with dozens of links to an Excel spreadsheet.
Currently when I change the source data in Excel, I have to got to the Word
table, I click Edit, Link and then Change Source for every entry in the Word
Table.
Is there a way to change the source file once and have all the items in the
Excel source file be automatically updated to the links in my Word table?
The format of the Excel sheet does not change, the links always point to the
same place, it is only the name of the spreadsheet which changes, and the
content obviously.

  #2  
Old April 6th, 2008, 02:27 PM posted to microsoft.public.word.tables
CraigV
external usenet poster
 
Posts: 2
Default Multiple Links from Word 2003 table to Excel 2003

I have had a maro written to "redirect" the links to the new Excel file.
Here it is:

Sub RedirectLinks()
'
' RedirectLinks Macro
' Macro created 1/31/2007 by Craig
'

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
End Sub


When you run it, it prompts you for the new full path and file name to link
to. You will notice the prompt is seeded with the current full path and file
name with some oddities: the backslash directory delimiter is always input
twice ("//" instead of "/"). I dont know why that is but you have to always
use the double backslash.

I hope this helps,
Craig

"Cyberjeff" wrote:

Stating the version of my office package for the previous post:
I have a Word template with dozens of links to an Excel spreadsheet.
Currently when I change the source data in Excel, I have to got to the Word
table, I click Edit, Link and then Change Source for every entry in the Word
Table.
Is there a way to change the source file once and have all the items in the
Excel source file be automatically updated to the links in my Word table?
The format of the Excel sheet does not change, the links always point to the
same place, it is only the name of the spreadsheet which changes, and the
content obviously.

  #3  
Old April 6th, 2008, 08:43 PM posted to microsoft.public.word.tables
Doug Robbins - Word MVP
external usenet poster
 
Posts: 8,239
Default Multiple Links from Word 2003 table to Excel 2003

' 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


--
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

"Cyberjeff" wrote in message
...
Stating the version of my office package for the previous post:
I have a Word template with dozens of links to an Excel spreadsheet.
Currently when I change the source data in Excel, I have to got to the
Word
table, I click Edit, Link and then Change Source for every entry in the
Word
Table.
Is there a way to change the source file once and have all the items in
the
Excel source file be automatically updated to the links in my Word table?
The format of the Excel sheet does not change, the links always point to
the
same place, it is only the name of the spreadsheet which changes, and the
content obviously.



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 04:05 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.