|
-
Dec 18th, 2009, 06:51 AM
#1
Thread Starter
Lively Member
[RESOLVED] Annoying...
Hi All,
I'm having a little issue with word 2003, in my office we use a custom normal.dot for just about everything (cooking, cleaning, storing beer, ya know the usual), one of the thing we used was an updatable field in the footer, showing the path of the document.
At initial open from the .dot, it would display document1 (as per the norm) then when you save a new doc from the .dot, close that document, and reopen it the footer would change to show the location path of where the docment is. That is when we used Word 2000.
after much searching I found this artical from MS (http://support.microsoft.com/kb/832897) about the fact that the auto update of fields a pone opening has been switched off in 2003 to allow a fast open response from word, but they kindly supplied a code to help with this.
IE:
Code:
Sub AutoOpen()
'
' AutoOpen Macro
' Macro created date by username
'
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
The code works the first time you open word, but after you save a doc close it then reopen to check if the code will work to diplay the new location, it doesn't. unless you switch views to normal then back to print layout, which is daft to do that every time.
Is there an way to amend the above code to update the code every time like word 2000.
-
Dec 21st, 2009, 08:44 PM
#2
Fanatic Member
Re: Annoying...
What event do you have the code under? Mine fires every time I open any document.
vb Code:
Private Sub Document_Open()
MsgBox "Dude, Test."
End Sub
-
Dec 22nd, 2009, 05:27 AM
#3
Thread Starter
Lively Member
Re: Annoying...
It was under auto-new, but that didn't work, I changed it doc open, but still requires me to switch between views before the changes happens
-
Dec 22nd, 2009, 06:07 AM
#4
Re: Annoying...
you can try this
ActiveDocument.Fields.Update
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Dec 22nd, 2009, 06:59 AM
#5
Thread Starter
Lively Member
Re: Annoying...
Thanks Westconn, I think its just doing it to spite me! i've put it in a new macro and set my security to medium, saved and exited, reopened and nothing, still won't update till I switch from print layout to normal view and back again...
would it be better if I placed the code in a different spot like under templateProject(Normal) - Microsoft Word Objects - This document. Would that make any difference?
-
Dec 22nd, 2009, 03:27 PM
#6
Re: Annoying...
I think its just doing it to spite me!
i just think word is like that
try togglefieldcodes twice, show the field codes then back
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|