Results 1 to 6 of 6

Thread: [RESOLVED] Annoying...

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2008
    Posts
    106

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

  2. #2
    Fanatic Member BillBoeBaggins's Avatar
    Join Date
    Jan 2003
    Location
    in your database, dropping your tables.
    Posts
    628

    Re: Annoying...

    What event do you have the code under? Mine fires every time I open any document.

    vb Code:
    1. Private Sub Document_Open()
    2.     MsgBox "Dude, Test."
    3. End Sub

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2008
    Posts
    106

    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

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jan 2008
    Posts
    106

    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?

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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
  •  



Click Here to Expand Forum to Full Width