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 » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Help with Word Excel Link through Macro



 
 
Thread Tools Display Modes
  #1  
Old November 13th, 2005, 05:52 PM
bob
external usenet poster
 
Posts: n/a
Default Help with Word Excel Link through Macro

Help, I am new to word macros and am trying to automate links between
word and excel on a project that will be turned over to others with
even less experience then me. My project has about 200 links although
I am thinking of breaking them up into smaller word docs to reduce the
amount of links. I have found that by having the linked (source)
spreadsheet open, this has sped up the process. I have the links set
to manual update as the spreadsheet has a habit of continuously running



even when I haven't changed anything with updates set to automatic
(seems like a good way to kill a hard drive).


My problem is that this code, which was taken from another posts, seems



to loop continuously and ends up with an 'insufficient memory' message
which causes the process to hang. Interestingly enough, the same
results happens with only 10 links on a test doc. If I update
manually{Edit / Links / Update}, then all works well and fast if I have



the excel source open at the time but I do not want to implement it
with a manual step like that.


The strangest part is that if I comment out the following statements,
then it seems to go through each field properly.
.Locked = False
.Update
.Locked = boolLinkState


Please help me. I'm sure it is my programming that is responsible but
can not find the answer. Also, can anyone point me to an online
reference manual for word 2002, excel 2002, or vba?


Pentium 4 w/ 512Mb cache
Operating system XP SP2
Word 2002
Excel 2002


Public Sub UpdateAllLinks()
Dim fldItem As Word.Field
Dim boolFieldLockState As Boolean
Dim boolLinkState As Boolean
fldcount = 0
' All fields in the MainTextStory
For Each fldItem In ActiveDocument.Fields


' Update any linked fields
If fldItem.Type = wdFieldLink Then


boolFieldLockState = fldItem.Locked
If boolFieldLockState Then fldItem.Locked = False


' Now try to update the linked fields
On Error Resume Next
With fldItem.LinkFormat
fldcount = fldcount + 1
If fldcount 90 Then
Stop
End If


boolLinkState = .Locked
.Locked = False
.Update
.Locked = boolLinkState
End With
On Error GoTo 0
fldItem.Locked = boolFieldLockState
End If
Next
End Sub

 




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

Similar Threads
Thread Thread Starter Forum Replies Last Post
take yet another lesson from wordperfect "reveal codes" wordperfect is superior General Discussion 5 May 11th, 2009 07:58 PM
How do I create a Word form like corel WP merge documents? dlee_at_mmsgov General Discussion 2 October 8th, 2005 06:29 AM
Envelope Address GR New Users 5 April 24th, 2005 09:48 PM
Macro help please: Excel data to word doc anna-maria General Discussion 5 June 30th, 2004 11:53 PM
word error mac General Discussions 1 May 6th, 2004 08:14 AM


All times are GMT +1. The time now is 01:16 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.