View Single Post
  #4   Report Post  
Charles Kenyon
 
Posts: n/a
Default

Greg, I made a couple of modifications to your macro because I sometimes use
fields like Fill-In fields that I do _not_ want to update. My revision is
below.

Option Explicit

Sub FileSaveAs()
' Based on macro shown in Greg Maxey's page at
' http://gregmaxey.mvps.org/File_Name_And_Path.htm
'
' Displays filename and path in document's title bar when saved using Save
As
' Also updates filename fields in document
'
Dialogs(wdDialogFileSaveAs).Show
System.Cursor = wdCursorNormal
ActiveWindow.Caption = ActiveDocument.FullName
Dim oStory As Range
Dim oField As Field
For Each oStory In ActiveDocument.StoryRanges
' oStory.Fields.Update ' replace this with the following For-Next
loop
For Each oField In oStory.Fields
If oField.Type = wdFieldFileName Then
oField.Update
End If
Next oField
If oStory.StoryType wdMainTextStory Then
While Not (oStory.NextStoryRange Is Nothing)
Set oStory = oStory.NextStoryRange
oStory.Fields.Update
Wend
End If
Next oStory
Set oField = Nothing
Set oStory = Nothing
ActiveDocument.Save ' Saves document with updated field(s)
End Sub

In my limited testing, it seems to work. I also added the final save
command. Of course, in a document with lots of fields my changes are going
to make the macro take a more time, I expect.
--
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.

"Greg Maxey" wrote in message
...
Milton

See:
http://gregmaxey.mvps.org/File_Name_And_Path.htm

--
Greg Maxey/Word MVP
A Peer in Peer to Peer Support

Milton Ross wrote:
The filename has been inserted into a document. I want the filename
to update automatically when saved as another name. Is this possible?