Mergefield count header/footer section word.

MarcosMarcos Member Posts: 55
Hello,

I have a hot question (for me it is).

Im building an CU for a word intergration in NAV2009, in the CU i use the Microsoft Word 12.0 Object Library automation control to perform several actions.
One of the things i want to achieve is to fill mergefields in header and footer sections.
To achieve this i need to know how many mergefields are used in this sections, the code to read the sections is clear to me and works.
But there is one thing what doesnt work, and that is the count function.
I only get the result of the first line in the header section of the document, example.

--WORD DOC
--HEADER
<<mergefield1>> <<mergefield2>>
<<mergefield3>>
--HEADER

If i do the following, MergeFieldCount := WordApp.Selection.Fields.Count;

The result is 2, so only the first line in the header section is counted.
Does anyone knows al solution for this ?? I searched the inet for a long time now but no answers.

Comments

  • MarcosMarcos Member Posts: 55
    Nobody, has a solution or the same problem.... :-k
  • ufukufuk Member Posts: 514
    Does your selection include all fields you want to count?
    Ufuk Asci
    Pargesoft
  • MarcosMarcos Member Posts: 55
    The selection contains the section.
  • ufukufuk Member Posts: 514
    I am not sure but it seems like your selection does not include all lines in header. Once I've done something about field count but they weren't in header. I also had a similiar problem and the reason was selection's scope. You should try workaround solutions like putting another values as header.field, activepane etc.
    Ufuk Asci
    Pargesoft
  • MarcosMarcos Member Posts: 55
    Ok thnx for the tip, i will try it out.
  • MarcosMarcos Member Posts: 55
    Problem solved, just lucky shot.
    But thnx for the reply.

    I changed the iunit paramter from 5 to 6, and now the count delivers a good result.

    WordApp.Selection.EndKey(iUnit,iExtend);


    greetzzz
Sign In or Register to comment.