Update File Linking

  • Thread starter Thread starter Richard
  • Start date Start date
R

Richard

Hi

I am new to this group so please excuse me for my English or anything else I
might say wrong..

I would like to update FileB which is linked to FileMaster automatically
when I open the document. Now, I need to do it manually. I am just afraid
that the user might forget to update and print out previous file of the
master. Hopw you understand what I am trying to achieve. How should I go
about doing it and how?

I can do some VBA programming in Access but Word is the first for me.

Thank you in advance
Richard
 
Hi Richard,

You can put the following into an AutoOpen macro in your document (which
will only work if macro security is set to allow it).

Sub AutoOpen()
' Written by Charles Kyle Kenyon 15 November 2001
' repaired by Jezebel
' All Story Field Updater - includetext
Dim oField As Field
Dim oStory As Range
' On Error Resume Next
For Each oStory In ActiveDocument.StoryRanges
' This goes into headers and footers as well as the regular document
Do
For Each oField In oStory.Fields
If oField.Type = WdFieldTypeIncludeText Then
oField.Update
End If
Next oField
Set oStory = oStory.Next
Loop Until oStory Is Nothing
Next oStory
End Sub

This assumes that your fields are IncludeText fields. The vba reference also
lists a constant of wdFieldTypeInclude and I'm not sure what that
references. someone else will probably have a more elegant solution.
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://www.mvps.org/word which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
Thanks Charles

works perfectly

Richard

Charles Kenyon said:
Hi Richard,

You can put the following into an AutoOpen macro in your document (which
will only work if macro security is set to allow it).

Sub AutoOpen()
' Written by Charles Kyle Kenyon 15 November 2001
' repaired by Jezebel
' All Story Field Updater - includetext
Dim oField As Field
Dim oStory As Range
' On Error Resume Next
For Each oStory In ActiveDocument.StoryRanges
' This goes into headers and footers as well as the regular document
Do
For Each oField In oStory.Fields
If oField.Type = WdFieldTypeIncludeText Then
oField.Update
End If
Next oField
Set oStory = oStory.Next
Loop Until oStory Is Nothing
Next oStory
End Sub

This assumes that your fields are IncludeText fields. The vba reference also
lists a constant of wdFieldTypeInclude and I'm not sure what that
references. someone else will probably have a more elegant solution.
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://www.mvps.org/word which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top