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

    Field Update in Primary Header Story (Word 97SR2)

    I have 2 fields in the section 2 header of a document (a Date field and a Page field). When the user clicks Save, my save function loops through all storyranges looking for Date fields with the intention of converting them to SaveDate fields.

    This works fine in the Main Text Story where most of the Date fields reside. But the code reports only 1 field (the Page) in the Primary Header Story. The Date field is as plain as day, but it's being ignored completely! A field count for the header story reveals only 1 field, when in fact 2 are there.

    Is this a MS Q article type bug? I have not found anything in the KB about this. Who knows?
    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>

  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: Field Update in Primary Header Story (Word 97SR2)

    I think maybe my approach is flawed.

    I'm looping through storyranges when I should be looping through sections.

    Re-coding in progres...
    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
    JustCallMeAl
    Guest

    Re: Field Update in Primary Header Story (Word 97SR2)

    Please consider the following:

    <pre>'Take note that the developers of Word97 seem to have made
    ' an oversight whereby, although the Document Object's
    ' StoryRanges Property's Item Method allows as arguments
    ' wdEvenPagesFooterStory, wdFirstPageFooterStory, and
    ' wdPrimaryFooterStory, none of these give access to the
    ' primary footer in the second section of a document when
    ' that footer's LinkToPrevious Property is False. The
    ' code below, though, by iterating first through the Sections
    ' Collection and then, within each of those, through the
    ' Footers Collection, avoids this problem.
    Dim sct As Section
    Dim hfr As HeaderFooter
    Dim fie As Field


    For Each sct In ActiveDocument.Sections
    For Each hfr In sct.Footers
    For Each fie In hfr.Range.Fields
    If fie.Type = wdFieldTime Then _
    fie.Result.Paragraphs.First.Range.Delete
    Next
    Next
    Next
    End Sub

    </pre>


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

    Re: Field Update in Primary Header Story (Word 97SR2)

    Well, well, well.

    So, it's confirmed. And your fix is quite elegant.

    I you posted that code before, sorry for not noticing. I was sure Storyrange looping worked -- until we started unlinking the headers/footers.

    Brilliant catch. I am indebted... <img src=/S/bravo.gif border=0 alt=bravo width=16 height=30>
    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>

Posting Permissions

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