Results 1 to 5 of 5
  1. #1

    odd page header + fields (Word (VBA))

    I'm writing a template for a manual. I want to ensure that each new chapter starts on an odd- numbered page. I can't use Odd-Page Section Breaks because this doesn't print the page headers, footers, and page numbers for the inserted blank pages. So I'm using an IF field as follows:- { IF { =MOD({ PAGE },2) } = 0 "[page break]" " "} I'm inserting if through VBA into the document when I start a new chapter.

    The field insertion is working fine, but the UPDATING of the fields is NOT working. What's happening is, when I update the fields - by doing a PRINT, Print Preview, Update all fields macro, or edit/select all/F9 - however I do it, it updates the fields on one pass only. So, as it updates the first occurrence of the field and puts the next chapter on an odd page, it moves all the other chapters down by a page, but doesn't re-update each field after moving it down a page in this way. So it ends up after each update that, apart from one more chapter being updated, the others are just switched around - odd page starts go to even pages and vice-versa.

    The only way I can get it to work is to update the document the number of times equal to the number of fields so that, one by one, they all come right in the end. Is there another way, or am I missing something in what I'm doing ?

    Thanks nik

  2. #2

    Re: odd page header + fields (Word (VBA))

    Shooting from the hip, how about trying this (this is UNTESTED).....

    <pre>Sub WoodyTestField()

    Dim fld As Field
    Dim wdDoc As Word.Document

    For Each fld In wdDoc
    Next fld

    End Sub

  3. #3

    Re: odd page header + fields (Word (VBA))

    hi justCallMeAl

    Thanks for the code. It doesn't work because it updates all the fields so that are correct at that point then when the document repaginates, all except the first one are wrong again after the first one has inserted the blank page.......arrrrrrrrgghhhhhh!!

    Any other ideas? Thanks

  4. #4

    Re: odd page header + fields (Word (VBA))

    Did you see this:

    <A target="_blank" HREF=></A>

    They point out some cautions. And, according to their code, it appears you have your {page break} in the wrong place.

  5. #5

    Re: odd page header + fields (Word (VBA))

    Hi BigAl,

    Thanks for your continued support! I had read the article and still couldn't get it working. The page number transposition shouldn't make a difference and I have tried it exactly as shown as well.

    But from what you say, I am on the right track atleast so I will see if I can get the small bugs sorted out to get this working.

    Thanks again


Posting Permissions

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