Reply
 
Thread Tools Display Modes
  #1   Report Post  
Milton Ross
 
Posts: n/a
Default automatically update inserted file name

The filename has been inserted into a document. I want the filename to update
automatically when saved as another name. Is this possible?
  #2   Report Post  
Charles Kenyon
 
Posts: n/a
Default

Not without putting a macro into your file. If the field is in a
header/footer, though, it will be updated when you print or do a print
preview.
--
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.

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



  #3   Report Post  
Greg Maxey
 
Posts: n/a
Default

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?



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





  #5   Report Post  
Charles Kenyon
 
Posts: n/a
Default

Because I don't like to mess with normal.dot and couldn't figure out how to
do a global pseudo AutoOpen in a different global template, I added the
following intercept to my global. It gives the filename and path on a
document save.

Sub FileSave()
' 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
' Also updates filename fields in document
'
ActiveDocument.Save
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

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

"Charles Kenyon" wrote in
message ...
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?









  #6   Report Post  
Greg
 
Posts: n/a
Default

Charles,

Good points. Next time I get around to working on the web page I will
make these changes. Thanks.

  #7   Report Post  
Charles Kenyon
 
Posts: n/a
Default

While this works, it also messes up automatic backup because the second save
zaps the original backup, replacing it with the document just before the
fields are updated but with any other changes. I have, on rare occasions,
had my rep saved by these automatic backups and am loathe to disable that
valuable feature. Given this, I've removed this macro from my own Add-In and
gone with the change to normal.dot originally suggested in Greg's web page.
--
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.

"Charles Kenyon" wrote in
message ...
Because I don't like to mess with normal.dot and couldn't figure out how
to do a global pseudo AutoOpen in a different global template, I added the
following intercept to my global. It gives the filename and path on a
document save.

Sub FileSave()
' 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
' Also updates filename fields in document
'
ActiveDocument.Save
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

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

"Charles Kenyon" wrote in
message ...
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?








Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatically update TOC on Print &/or Save FFW Microsoft Word Help 4 February 20th 14 11:44 PM
Inserting a file automatically Joe Microsoft Word Help 1 February 11th 05 03:40 AM
Automatically update style Øyvind Alsos Microsoft Word Help 2 January 14th 05 01:19 PM
How do you REALLY turn off automatically update styles in Word 200 College Student Microsoft Word Help 1 January 8th 05 11:17 PM
preserving formatting of file that's been inserted into an open do Talia38 Page Layout 1 December 10th 04 09:33 PM


All times are GMT +1. The time now is 11:20 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"