Microsoft 开发人员网络 > 论坛主页 > Visual Studio Tools for Office > Post-process the result of the INDEX
提出问题提出问题
 

已答复Post-process the result of the INDEX

  • 2009年7月1日 16:21Karthik.SK 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     
    Dear friends,

    I had an issue with word indexing . I had posted my question initially in "word general questions" which is below for your reference


    "> I have a question is indexing.. If i am doing indexing for integer/numeric
    > starting values like "1-North street" its displaying in index under the
    > heading "1".
    >
    > Is there any option to display all the numeric starting values under a
    > common heading(say numerics)????"


    and the reply i have got from few is

    "I think there isn't. You'd have to post-process the result of the INDEX
    field each time you update the index.

    If you need this functionality a lot, a macro doing the post-processing
    (basically deleting all the 1/2/3/... headings in the TOC and inserting
    one "Numerics" heading) is certainly feasible."

    I am not exactly able to catch up the point here. Do anybody got worked out samples for this issue?

    Thanks in advance.

答案

  • 2009年7月3日 10:56Cindy MeisterMVP, 版主用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     已答复
    Hi Karthik

    I don't have any code for this - I've never tried this particular exercise...

    What the person answering means is that you need to "walk" the Index entries (TOC was probably just a lapse of concentration) - probably paragraphs, but it will depend on the type of Index. Where you find a number as the first character of an entry, your code would delete that and any other extraneous characters (dashes, spaces, etc). Do that until the numbers stop.

    At the same time, also delete the "section heading" for each number (1, 2, 3, etc).

    And, of course, at the top insert the "section heading" you want to see.

    As the person notes, this code would have to be run again everytime the Index is updated. This is because updating a field will erase any editing done to the field text.
    Cindy Meister, VSTO/Word MVP
  • 2009年7月4日 10:33Cindy MeisterMVP, 版主用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     已答复
    Hi Karthik

    In that case, all you need to do is delete those headings and insert your own. The field result can be manipulated just like any other text in the document. What you do just isn't "permanent" (will be lost when the field updates).
    Cindy Meister, VSTO/Word MVP

全部回复

  • 2009年7月3日 10:56Cindy MeisterMVP, 版主用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     已答复
    Hi Karthik

    I don't have any code for this - I've never tried this particular exercise...

    What the person answering means is that you need to "walk" the Index entries (TOC was probably just a lapse of concentration) - probably paragraphs, but it will depend on the type of Index. Where you find a number as the first character of an entry, your code would delete that and any other extraneous characters (dashes, spaces, etc). Do that until the numbers stop.

    At the same time, also delete the "section heading" for each number (1, 2, 3, etc).

    And, of course, at the top insert the "section heading" you want to see.

    As the person notes, this code would have to be run again everytime the Index is updated. This is because updating a field will erase any editing done to the field text.
    Cindy Meister, VSTO/Word MVP
  • 2009年7月3日 12:32Karthik.SK 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     
    Cindy,


    Here i don't need to modify the entries. let the entries be starting  with numerics or extraneous characters, but i need to change all those numeric entries to be displayed under a common heading.


    Thx in advance
    Karthik


  • 2009年7月4日 10:33Cindy MeisterMVP, 版主用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     已答复
    Hi Karthik

    In that case, all you need to do is delete those headings and insert your own. The field result can be manipulated just like any other text in the document. What you do just isn't "permanent" (will be lost when the field updates).
    Cindy Meister, VSTO/Word MVP
  • 2009年7月5日 5:55Karthik.SK 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     
    Hi Cindy,

    Is there any macro or sample available to get the headings of the index?

    -karthik
  • 2009年7月6日 8:32Cindy MeisterMVP, 版主用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     

    I know of none. In any case, it's going to depend on exactly how the Index is generated (the particular properties used).


    Cindy Meister, VSTO/Word MVP