|
|
 |
| Word VBA Discuss using VBA to program Word. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Word VBA section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

September 3rd, 2009, 11:51 AM
|
|
Registered User
|
|
Join Date: Sep 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Faster way to update external links in a large document
I have a large document (~100 pages) and it has hundreds of links to a single excel file because the document is used for several different jobs. I have created a macro that udates the source to all of the links very quickly but I need a code that will update the links faster. I believe the document is opening and closing the excel file for every link. Right now it is taking approximately 2 hours to update the links. Please help! Thanks 
|

September 3rd, 2009, 11:10 PM
|
|
Friend of Wrox
|
|
Join Date: Sep 2005
Location: , , .
Posts: 420
Thanks: 0
Thanked 14 Times in 14 Posts
|
|
Hi
Do you mean to say the Word document opens the Excel and checks for specific info for each link?
Can you post your code snippet so that we can optimize it
Cheers
Shasur
|

September 4th, 2009, 09:28 AM
|
|
Registered User
|
|
Join Date: Sep 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
In my word document, I have a lot of words that are linked to different cells in one excel file. If I highlight the whole document, in word, and F9 to update the links, it takes about 2 hours. I was looking for a code that would update the links faster and more efficiently. The code that I have now is for updating the source (because the file is copied and moved into new folders). This code I don't want to change because I want it to be a separate action. The only code I have found to update the links is as follows:
Sub updateLinks()
'created to update the links
'added August 25, 2009 by Melissa Murphy
Dim oStory As Range
Dim oField As Field
For Each oStory In ActiveDocument.StoryRanges
For Each oField In oStory.Fields
oField.Update
Next oField
Next oStory
End Sub
But this one takes right at two hours to update all of the links as well.
Thanks for your time!
|

September 5th, 2009, 11:41 AM
|
|
Friend of Wrox
|
|
Join Date: Sep 2005
Location: , , .
Posts: 420
Thanks: 0
Thanked 14 Times in 14 Posts
|
|
Hi
Since you are updating all fields, can you try the following:
ActiveDocument.Fields.Update
Cheers
Shasur
|

September 5th, 2009, 11:55 AM
|
|
Registered User
|
|
Join Date: Sep 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thank you for the help but that doesn't make the links update any faster. It still takes the same almost 2 hours.
Thanks,
Melissa
|

September 5th, 2009, 10:59 PM
|
|
Friend of Wrox
|
|
Join Date: Sep 2005
Location: , , .
Posts: 420
Thanks: 0
Thanked 14 Times in 14 Posts
|
|
Hi Mellisa
I am afraid if you are looping through the Word.story for this too
Can you please try
Code:
Sub updateAllLinks()
ActiveDocument.Fields.Update
End Sub
If this is not the one, can you post your modified code?
Cheers
Shasur
|

September 8th, 2009, 08:51 AM
|
|
Registered User
|
|
Join Date: Sep 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thank you for your help again. I have posted the same code that you have provided, to update the links, but it does not increase the wait time for the document to update all 200+ links.
Thanks,
Melissa
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |