Results 1 to 4 of 4
  1. #1
    zeke
    Guest

    updating fieldcodes in a header

    This one is driving me up the wall. I've been trying to update my fields that are located in my header section. I've been trying to use Activedocument.fields.update but it doesn't seem to update header and footer fields. If anyone can help it would be greatly appreciated.

  2. #2
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: updating fieldcodes in a header

    Of course activedocument.fields.update doesn't work. MS wants you to work instead...


    I suppose there is some logic to it, but we've all cut our teeth on this one.

    You have to loop through the field object in the header/footer story object in order to update fields in that "story". This should get you started:

    <pre>For Each aStory In ActiveDocument.StoryRanges
    If aStory.Information(wdHeaderFooterType) Then
    For Each aField In aStory.Fields
    With aField
    .ShowCodes = False
    .Update
    End With
    Next
    End If
    next
    </pre>


    If there's a better way, somebody'll chime in...
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  3. #3
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,049
    Thanks
    124
    Thanked 119 Times in 116 Posts

    Re: updating fieldcodes in a header

    This is because the header/footer (and textboxes) are not "in" the document but in separate "stories."

    See <A target="_blank" HREF=http://www.mvps.org/word/FAQs/MacrosVBA/UnlinkFldsFromHeaders.htm> Unlink all fields in headers and footers</A> for the macro language you need. Replace "Unlink" with "Update" and you should be rolling.
    Charles Kyle Kenyon
    Madison, Wisconsin

  4. #4
    JustCallMeAl
    Guest

    Re: updating fieldcodes in a header

    Depending on why you want the field codes in headers/footers to be updated, I believe the option Tools, Options, Print, Update Fields will update the fields when you send the document to print OR when you do a Print Preview. Of course, you could always try this little bit of code, it does make the screen flash a bit, but not too badly.

    <pre> Application.ScreenUpdating = False
    activedocument.PrintPreview
    activedocument.ClosePrintPreview
    Application.ScreenUpdating = True
    Application.ScreenRefresh</pre>


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •