To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
VBForums  

VB Wire News
Article :: Building Dynamic Systems with Expressions in .NET
How Is XML Like An Interface?
Understanding Covariance and Contravariance
Print VS 2010 Keyboard Shortcut References in Letter (8.5x11in) and A4 (210×297mm) Sizes
Updated Productivity Power Tools



Go Back   VBForums > Visual Basic > Office Development

Reply Post New Thread
 
Thread Tools Display Modes
Old Feb 26th, 2010, 05:54 AM   #1
Kubull
Lively Member
 
Join Date: Jan 08
Posts: 98
Kubull is an unknown quantity at this point (<10)
Post Word 2003 auto field update

Hi all,

Bit of a golden oldie for ya! We use Word 2003 and use a field in footer to show the file path of the document, I found out later that the auto field update isn't included in 2003, so I used the MS advice and added the code that does it.

Works a treat.... but our users have found that every time they save a document it updates the field with the new location, and records it as an alteration, which requires another save when they close the doc down, not a major issue, but a slight annoyance, is there a way to re jig the code so as it becomes a part of the save process so as it doesn't require another save?

Code:
Sub UpdateDocFields()

' Called by ModSave:FileSave and FileSaveAs and modOpen:FileOpen
' Updates fields in the active document
' Macro created 08/02/2010 by Robert Morley

   Dim aStory As Range
   Dim aField As Field
  
   For Each aStory In ActiveDocument.StoryRanges

      For Each aField In aStory.Fields
         aField.Update
      Next aField

   Next aStory

End Sub
Kubull is offline   Reply With Quote
Old Feb 26th, 2010, 06:05 AM   #2
koolsid
Comfortably Numb
 
koolsid's Avatar
 
Join Date: Feb 05
Location: Mumbai, India
Posts: 9,300
koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)
Re: Word 2003 auto field update

Why not call the code only in the following sub? This will ensure that you don't have to call it manually?

Code:
Private Sub Document_Close()

End Sub
__________________
A good excercise for the Heart is to bend down and help another up...
Please Mark your Thread "Resolved", if the query is solved...
'~~> If a post has helped you then Please Rate it by Clicking "Rate This Post" on the left hand side of the post!
VB 6.0 Code Generator for VB6, Working with Windows Registry, Creating Access Database via Code, Listview Sub Item Image, Common Dialog Control
VBA 6.5
Excel Data Validation, Conditional Formating, Pivot Table, Column No to Column Name, Scroll Bars, Music Player, Creating Splash Screen
Powerpoint Creating Charts
Misc Ascii Table, Chit Chatters, USB Pendisk - Trojans, MyFlickr

MyGear: Sony VGN-FZ27G with a triple boot between (XP + Office 2003 + VB6), (VISTA + Office 2007 + VS2008) and (Win7 + Office 2010 + VS2010)
koolsid is offline   Reply With Quote
Old Feb 26th, 2010, 07:10 AM   #3
Kubull
Lively Member
 
Join Date: Jan 08
Posts: 98
Kubull is an unknown quantity at this point (<10)
Re: Word 2003 auto field update

Cheers Koolsid,

Does that mean the close command would be the new save? to be honest that more of less what we told them to do, by default word will ask them to save it if they haven't already. but the flaw in our plan is that we have a custom save frm we would like our staff to use, or they'll end up deleting anything and everything... I know it sounds like we're spoon feeding them
Kubull is offline   Reply With Quote
Old Feb 26th, 2010, 07:18 AM   #4
koolsid
Comfortably Numb
 
koolsid's Avatar
 
Join Date: Feb 05
Location: Mumbai, India
Posts: 9,300
koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)
Re: Word 2003 auto field update

Save I see your save routine?
__________________
A good excercise for the Heart is to bend down and help another up...
Please Mark your Thread "Resolved", if the query is solved...
'~~> If a post has helped you then Please Rate it by Clicking "Rate This Post" on the left hand side of the post!
VB 6.0 Code Generator for VB6, Working with Windows Registry, Creating Access Database via Code, Listview Sub Item Image, Common Dialog Control
VBA 6.5
Excel Data Validation, Conditional Formating, Pivot Table, Column No to Column Name, Scroll Bars, Music Player, Creating Splash Screen
Powerpoint Creating Charts
Misc Ascii Table, Chit Chatters, USB Pendisk - Trojans, MyFlickr

MyGear: Sony VGN-FZ27G with a triple boot between (XP + Office 2003 + VB6), (VISTA + Office 2007 + VS2008) and (Win7 + Office 2010 + VS2010)
koolsid is offline   Reply With Quote
Old Feb 26th, 2010, 08:48 AM   #5
Kubull
Lively Member
 
Join Date: Jan 08
Posts: 98
Kubull is an unknown quantity at this point (<10)
Re: Word 2003 auto field update

It's a big one... here goes!

Edit* Didn't like it please see the attached
Attached Files
File Type: txt Save Command sub.txt (10.3 KB, 14 views)
Kubull is offline   Reply With Quote
Old Feb 26th, 2010, 09:17 AM   #6
koolsid
Comfortably Numb
 
koolsid's Avatar
 
Join Date: Feb 05
Location: Mumbai, India
Posts: 9,300
koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)
Re: Word 2003 auto field update

Use your form to do a save as and then simply call this in the Document_Close event

Code:
ActiveDocument.Save
__________________
A good excercise for the Heart is to bend down and help another up...
Please Mark your Thread "Resolved", if the query is solved...
'~~> If a post has helped you then Please Rate it by Clicking "Rate This Post" on the left hand side of the post!
VB 6.0 Code Generator for VB6, Working with Windows Registry, Creating Access Database via Code, Listview Sub Item Image, Common Dialog Control
VBA 6.5
Excel Data Validation, Conditional Formating, Pivot Table, Column No to Column Name, Scroll Bars, Music Player, Creating Splash Screen
Powerpoint Creating Charts
Misc Ascii Table, Chit Chatters, USB Pendisk - Trojans, MyFlickr

MyGear: Sony VGN-FZ27G with a triple boot between (XP + Office 2003 + VB6), (VISTA + Office 2007 + VS2008) and (Win7 + Office 2010 + VS2010)
koolsid is offline   Reply With Quote
Old Feb 26th, 2010, 09:26 AM   #7
Kubull
Lively Member
 
Join Date: Jan 08
Posts: 98
Kubull is an unknown quantity at this point (<10)
Re: Word 2003 auto field update

Thanks koolsid,

Alas our users are 1.technophobes and 2. creatures of habbit. if I apply a save into the close, the users will by habbit click save as, filling the necessary then close the doc and be asked to save again. unless you mean that the adding of the activedoc.save removes that prompt and just saves the doc?
Kubull is offline   Reply With Quote
Old Feb 26th, 2010, 10:45 AM   #8
koolsid
Comfortably Numb
 
koolsid's Avatar
 
Join Date: Feb 05
Location: Mumbai, India
Posts: 9,300
koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)
Re: Word 2003 auto field update

Quote:
unless you mean that the adding of the activedoc.save removes that prompt and just saves the doc?
Yes.

It's something like you do a file save as and then keep on clicking Ctrl + S

What we are doing is a Ctrl + S before closing the document.
__________________
A good excercise for the Heart is to bend down and help another up...
Please Mark your Thread "Resolved", if the query is solved...
'~~> If a post has helped you then Please Rate it by Clicking "Rate This Post" on the left hand side of the post!
VB 6.0 Code Generator for VB6, Working with Windows Registry, Creating Access Database via Code, Listview Sub Item Image, Common Dialog Control
VBA 6.5
Excel Data Validation, Conditional Formating, Pivot Table, Column No to Column Name, Scroll Bars, Music Player, Creating Splash Screen
Powerpoint Creating Charts
Misc Ascii Table, Chit Chatters, USB Pendisk - Trojans, MyFlickr

MyGear: Sony VGN-FZ27G with a triple boot between (XP + Office 2003 + VB6), (VISTA + Office 2007 + VS2008) and (Win7 + Office 2010 + VS2010)
koolsid is offline   Reply With Quote
Old Feb 26th, 2010, 10:56 AM   #9
Kubull
Lively Member
 
Join Date: Jan 08
Posts: 98
Kubull is an unknown quantity at this point (<10)
Re: Word 2003 auto field update

Thanks Sid,

Alas I've tested it on a user, it works but they raised a good point, if they edit a doc to the point that it would take longer the undo, then to redo, they would normally just close the doc and start over, but this edit would save it even if they don't want to, Nightmare! no worries like I said, it's no biggie, it's only one pop up that just reminds them to save their work, can't remind them anymore then that I guess, the more the merrier lol

Thanks for the help anyways
Kubull is offline   Reply With Quote
Old Feb 26th, 2010, 11:11 AM   #10
koolsid
Comfortably Numb
 
koolsid's Avatar
 
Join Date: Feb 05
Location: Mumbai, India
Posts: 9,300
koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)koolsid is a name known to all (1000+)
Re: Word 2003 auto field update

OK, if your query is solved then do remember to mark the thread resolved
__________________
A good excercise for the Heart is to bend down and help another up...
Please Mark your Thread "Resolved", if the query is solved...
'~~> If a post has helped you then Please Rate it by Clicking "Rate This Post" on the left hand side of the post!
VB 6.0 Code Generator for VB6, Working with Windows Registry, Creating Access Database via Code, Listview Sub Item Image, Common Dialog Control
VBA 6.5
Excel Data Validation, Conditional Formating, Pivot Table, Column No to Column Name, Scroll Bars, Music Player, Creating Splash Screen
Powerpoint Creating Charts
Misc Ascii Table, Chit Chatters, USB Pendisk - Trojans, MyFlickr

MyGear: Sony VGN-FZ27G with a triple boot between (XP + Office 2003 + VB6), (VISTA + Office 2007 + VS2008) and (Win7 + Office 2010 + VS2010)
koolsid is offline   Reply With Quote
Reply

Tags
word

Go Back   VBForums > Visual Basic > Office Development


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

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

Forum Jump


All times are GMT -5. The time now is 07:56 PM.





Acceptable Use Policy

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.