none
Q | A challenge for Who understands in VB and WORD RRS feed

  • Question

  • Sorry for the English. I was helped by Google...

    Hello, I am writing a dictionary in WORD, just having trouble during writing:
    You know the title of every page in the dictionary, there are values of what at the top of every page at the end of each page, such as: a - about ...
    How to do it in WORD?
    I tried to do this by combining macro fields, but could not.

    ---

    I did not write VB code. Unfortunately I can not write at a reasonable level in VB.
    What I do know is recording a macro. So I tried after following a recording, do Insert ==> field, and look for appropriate field. Only I was looking for a field to retrieve the value for the first and last page (the appropriate fields in the dictionary), but could not find a field suitable for conducting this mission. I tried to find a field that retrieves a macro, so do macro, says the field to open the macro.
    And ... I did find something similar, it's called: MacroButton. This field allows you to create in the WORD field is actually a button that when clicked on is running a macro that we created.
    But the problems which it is not updated automatically on "Update Fields", like all other fields (eg: If I set fields Time / Date in the document, I can update them all at once by Ctrl A and update fields ... Although Field MacroButton not updated in this manner but have to go on any field such field in the document and click on it to update it.)
    What I'm looking for now? Can I create another field in WORD, similar to MacroButton could run a macro that we created, just like any other updated fields in the document, without having to click on each field and field. So that every time I update fields in the macro starts.
    So I can record a macro that retrieves the first entry on the page or the last entry on the page. Then I create a field that will activate the macro and accept the recall, will place these fields appear in the title every page, and the field will retrieve all updates and updating the values that you want every page.
    It was the direction of my my solution.
    I'd love to see if possible to do this in WORD, or accept any other solution better.

    Sunday, November 28, 2010 4:43 PM

Answers

  •  
    The problem is: Every time I am adding new lines in my dictionary, the whole lines in the document change. Because of that I need to redefine the head words over and

    over every time I'm adding new words. "Fields" should do it automatically. [Because of that I looked for MacroByUpdate field instead of MacroButton]

    I've tried it and I'm sorry. Your solution is good but not enough. It must be a better solution. Please suggest another solution.

    Put the StyleRef field into the document HEADER or FOOTER.

    Format all the terms with the character style (not just the first or last on the page).

    The StyleRef field will automatically pick up the first term formatted with that style on the current page (like a dictionary).

    If you also want to see the last term, insert a second style ref field and include the \l switch ("Instructs Word to search from the bottom of the current page, rather than from the top.")


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by a04 Tuesday, November 30, 2010 7:12 PM
    Tuesday, November 30, 2010 9:37 AM
    Moderator
  •     > Your solution is good but not enough.
     
    I'm sorry if you can't make it work, but it is the way to do exactly what you ask; there is no better way. Read up on the use of Styles to make sure you are doing everything else in a good way, and make sure all your headwords, and only those words, use the character style you have defined and are using in the Styleref fields.
     

    Enjoy,
    Tony
    www.WordArticles.com
    • Marked as answer by a04 Tuesday, November 30, 2010 7:12 PM
    Tuesday, November 30, 2010 9:53 AM

All replies

  • The field you want is "StyleRef".
     
    First off, define a style for your head words, and put them, and only them, in that style.
     
    Then insert two StyleRef fields in the Page Header - both referencing your Style (chosen from the dropdown in the Insert Field dialog) - one with all defaults, the other with "Search from the bottom of the Page" checked.
     
     

    Enjoy,
    Tony
    www.WordArticles.com
    Sunday, November 28, 2010 5:36 PM
  • Hello,

    Very Good , But not enough...

    I've followed your instructions and tried it. It's nice but I found 2 disadvantges/problems:

    1. StyleRef refers to style of Paragraph and not of a Font. I need in the Page Header only one word and not all the Paragraph. (Try it to understand..)
    2. If I want to add more words later in the dictionary, the first and the last words (values, to be exact) in each page will be changed and will be different from what I had defined...

    We have to Keep trying to achive the right way to the target. thanks.

    Sunday, November 28, 2010 11:49 PM
  • Use a character style, and apply it just to the head words, instead of a paragraph style applied to the whole paragraph.
     

    Enjoy,
    Tony
    www.WordArticles.com
    Monday, November 29, 2010 10:11 AM
  • I think StyleRef is searching for a paragraph style and not for a character style.

    I got Error, when I tried it.

    Please try it, and let me know.

    Thank you 

    Monday, November 29, 2010 2:26 PM
  • The styleref field looks for the style name. If that style is a character style then it will reproduce the characters formatted with that named style. It it is a paragraph style it will reproduce the paragraph.



    <a04> wrote in message news:5a424321-1a20-49dd-a25b-21188166c8fa@communitybridge.codeplex.com...

    I think StyleRef is searching for a paragraph style and not for a character style.

    I got Error, when I tried it.

    Please try it, and let me know.

    Thank you


    Graham Mayor - Word MVP
    www.gmayor.com
    Posted via the Communities Bridge
    http://communitybridge.codeplex.com/
    Monday, November 29, 2010 2:41 PM
  • Yes. You was right. I don't know why, but even though I am marking only a character and saving it as a style, It is saved by deafult as a paragraph style (?!). To acheive character style it is needed to be done manually from the menu...

    Great. But... We still need to cope with the second problem (above)...

    Keep on.. Good Luck

    Monday, November 29, 2010 6:03 PM
  • What second problem? Provided the style is applied to the new words being added, Word will take care of the rest without you doing anything.
     

    Enjoy,
    Tony
    www.WordArticles.com
    Monday, November 29, 2010 6:51 PM
  •  
    The problem is: Every time I am adding new lines in my dictionary, the whole lines in the document change. Because of that I need to redefine the head words over and

    over every time I'm adding new words. "Fields" should do it automatically. [Because of that I looked for MacroByUpdate field instead of MacroButton]

    I've tried it and I'm sorry. Your solution is good but not enough. It must be a better solution. Please suggest another solution.

    Thank you.

    Tuesday, November 30, 2010 8:57 AM
  •  
    The problem is: Every time I am adding new lines in my dictionary, the whole lines in the document change. Because of that I need to redefine the head words over and

    over every time I'm adding new words. "Fields" should do it automatically. [Because of that I looked for MacroByUpdate field instead of MacroButton]

    I've tried it and I'm sorry. Your solution is good but not enough. It must be a better solution. Please suggest another solution.

    Put the StyleRef field into the document HEADER or FOOTER.

    Format all the terms with the character style (not just the first or last on the page).

    The StyleRef field will automatically pick up the first term formatted with that style on the current page (like a dictionary).

    If you also want to see the last term, insert a second style ref field and include the \l switch ("Instructs Word to search from the bottom of the current page, rather than from the top.")


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by a04 Tuesday, November 30, 2010 7:12 PM
    Tuesday, November 30, 2010 9:37 AM
    Moderator
  •     > Your solution is good but not enough.
     
    I'm sorry if you can't make it work, but it is the way to do exactly what you ask; there is no better way. Read up on the use of Styles to make sure you are doing everything else in a good way, and make sure all your headwords, and only those words, use the character style you have defined and are using in the Styleref fields.
     

    Enjoy,
    Tony
    www.WordArticles.com
    • Marked as answer by a04 Tuesday, November 30, 2010 7:12 PM
    Tuesday, November 30, 2010 9:53 AM

  • Congratulations!!! We did it!!!

    There was a misunderstanding.  I translated "head words" like "The words need to appear in the header"... now I understand this means the terms.

    Thank you Tony and Cindy Meister. You are really professionals.

    Have good life!

    Tuesday, November 30, 2010 7:12 PM