Consulting

Page 2 of 2 FirstFirst 1 2
Results 21 to 31 of 31

Thread: Word report generation page/header problem.

  1. #21
    Site Admin
    The Princess
    VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location
    fumei: Use a secion break. Ok, what did you mean Make the new Section not Same as previous.
    Open a blank Word doc, Mike.
    Insert a section break (next page).
    Go to view header and footer.
    See that "Same as previous"?
    You don't want that.
    There's a button on the header/footer toolbar to turn it off.
    ~Anne Troy

  2. #22
    Site Admin
    The Princess VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location
    Also, if I were you, I'd dump the data from SQL to CSV, do a mail merge...
    ~Anne Troy

  3. #23
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    I was trying to write some text then add a section break and add some more text in the second section. Then i went to the first section's headers/footers and named it "Section 1", after that I went into the second Section's headers/footers and named it "Section 2". After i did that section 1's header/footer also became "Section 2". So headers/footers are not section dependant.
    Sorry, but in fact the example your wrote proves the point.

    1. You write into Section header - "Section 1"

    2. You write into Section 2 header - "Section 2"

    If Section 2 is still set for Same as previous....and you are updating it, what exactly are you doing? You are making Section 2 header content = "Section 2". Yes. And since Section = Same as previous.....then it makes sense that because you are, in fact updating ONE object (shared by both Section 1 and Section 2), then...yes, the content updates for the header in Section 1.

    Keeping it simple (by ignoring any settings for Different first page, Different Odd/Even), Word determines headers like this:

    Section 1:
    header object always exists.

    Section 2:
    If .LinkToPrevious = True then header object values are BYREF to header object Section 1. Any changes are also BYREF back to the object.

    If .LinkToPrevious = False then header object values are BYVAL to the values given to it.

    Section 3:
    If .LinkToPrevious = True AND
    Section 2 .LinkToPrevious = True Then
    header object values are BYREF to header object Section 1. Any changes are also BYREF back to the object.

    If .LinkToPrevious = True AND
    Section 2 .LinkToPrevious = False Then
    header object values are BYREF to header object Section 2. Any changes are also BYREF back to the object.

    If .LinkToPrevious = False then header object values are BYVAL to the values given to it.

    Section 4 etc etc etc.

    They are very explicitly section dependent. It is just that it is a confusing, and perhaps not very intuitive, part of the object model. When you changed Section 2, because it is same as previous, Section 1 changed as well.

    Try making Section 2 NOT same as, Then go back, do something with Section 1, then do something with Section 2. Section 1 should be whatever you put there.

  4. #24
    VBAX Regular
    Joined
    Mar 2005
    Posts
    67
    Location
    This might be what i was looking for. Thanks very much guys for your help.


    I will keep you posted on how it goes.
    Mike

  5. #25
    VBAX Regular
    Joined
    Mar 2005
    Posts
    67
    Location
    Hey guys. Ok everything is working out ok except the

    Page { PAGE } out of { SECPAGES }

    Secpages is always = 3.
    This is how many pages the survey is actually in the beggining but after i write into it. It get to 4 - 5 pages. Shouldnt SECPAGES change from 3 to 4 or 5.

    I use all line breaks except all the way at the end of the survey I put a new line section break.
    Do i have to write the whole document and then put the

    Page { PAGE } out of { SECPAGES }
    in the header?

    What do you guys think?

    Thanks for all the help
    Mike

  6. #26
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    You need to post code. In addition:
    I use all line breaks except all the way at the end of the survey I put a new line section break.
    What does this mean? I do not understand, at all, what this means.

    You use line breaks....uh, what do you mean?

    SECPAGES is, well, as you may guess, the number of pages in the current section.

    Doc has ONE section, with 3 pages. {PAGE} of {SECPAGES} will return:

    Page 1 of 3
    Page 2 of 3
    Page 3 of 3

    A NEW section inserted. You then add 2 pages into that section. {PAGE} of {SECPAGES} will return:

    Page 1 of 3
    Page 2 of 3
    Page 3 of 3
    Page 4 of 2
    Page 5 of 2

    {PAGE} is the calculated page number. It is NOT an absolute number. In the above example, if you make the new section break start numbering at 1, then the document looks like (same fields {PAGE} of {SECPAGES})

    Page 1 of 3
    Page 2 of 3
    Page 3 of 3
    Page 1 of 2
    Page 2 of 2

    As I do not know if you are using Section breaks properly, and I can not see code, I hope the above may help. You can leave the same fields in the header, just add a renumbering if that is what you want to do.

  7. #27
    VBAX Regular
    Joined
    Mar 2005
    Posts
    67
    Location
    Messing with this right now. I can post code but its C# though. Im using a C# .net app to call VBA.

    I have this code:
    [VBA]
    Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _

    PreserveFormatting:=False

    [/VBA]
    What is the actual value of Selection.Range. I tried looking in the object browser and searching for this and could not find it.


    Mike

  8. #28
    Administrator
    VP-Knowledge Base VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    Hi Mike,

    There is no constant value for Selection.Range

    A range or selection object is your ticket to travel trough the document and access the properties & methods you need on the way.

    A range or selection object represent a area in the document with a starting point (.Start) and ending point (.End) (Continues)

    So you can set you own Range to where you want to insert the field.

    But to answer your question better perhaps you could add some more detail to the question..What are you trying to do and whats not working.
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

  9. #29
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Huh? I am sorry, but you totally through me for a loop.

    The code inserts a empty field. What on eath has this got to do with Sections, section breaks, or header problems?????

    Are you actually asking what is the value of Selection.Range?

  10. #30
    Administrator
    VP-Knowledge Base
    VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    Quote Originally Posted by fumei
    Huh? I am sorry, but you totally through me for a loop.

    The code inserts a empty field. What on eath has this got to do with Sections, section breaks, or header problems?????
    Hi Gerry,

    Yes good question...I must admit I didn't read the whole question..
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

  11. #31
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    To expand on Joost's post...

    Selection.Range is precisely that. It is the Range of the Selection. If the Selection is a point (sometimes known as the Insertion point - incorrectly I may add; it is the Selection point) then the Range Start ( as ALL ranges have Start and End) = range End.

    Selection.Range.Start = 4589
    Selection.Range.End = 4589 means these Selection is a point.

    Selection.Range.Start = 4589
    Selection.Range.End = 4599 means the Selection Range covers 11 characters. The numbers are inclusive. They are Long integers BTW, and are based on the very first character in the document = 0.

    That aside, again...what is the relevance to this?????????

Posting Permissions

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