none
Setting styles order RRS feed

  • Question

  • Hi,

    I've developed a Word 2010 template with a mix of user-defined and built-in styles. The styles are set to sort order "Recommended" and each style has the correct priority. The template also contain a form which allowes the user to enter pre-defined text. Everything works fine until the form is closed with unLoad, then the priority changes and the styles order gets messed up.

    Is there any way to set priority with VBA, and also sort the styles with recommended order?

    Regards,

    Roger

    Friday, September 6, 2013 8:27 AM

Answers

  • Heh, welcome to my world :-) Sometimes it just helps to discuss it with someone who hasn't a clue about the project, to get a different point of view and make you go at it from a different angle.

    It's not the first time we've found that an AutoText (or BuildingBlock) is bringing unwanted styles information into a document and "messing things up". I'm keeping an unofficial list of that kind of thing, so I'm glad to have interacted with you.

    Good that things are working, now!


    Cindy Meister, VSTO/Word MVP, my blog

    • Marked as answer by RogerZen Friday, September 13, 2013 9:13 AM
    Thursday, September 12, 2013 5:18 PM
    Moderator

All replies

  • Could you give us some instructions to reproduce your problem, please?

    Cindy Meister, VSTO/Word MVP, my blog

    Friday, September 6, 2013 2:59 PM
    Moderator
  • I'll do my best... :)

    In my template I've kept the styles Heading 1-4 and added some own styles for bullet lists and text. I've set the styles list to recommended order. Every style has a priority so it will be easy to find in the Quick Style Gallery, Header 1-4 and Normal text style has priority 1, different kind of lists has priority 2 and so on.

    In the templeate I've also created a userform with some textfields and dropdowns. From that userform text is inserted in building blocks on the document when clicking on a button.

    The problem occurs when a user clicks the "Insert text"-button in the userform. The styles Heading 1 and 2 suddenly gets priority 10 and is sorted in another place in the Quick Style Gallery. And it's only when the userform is closed with "unLoad form" this happens, otherwise the template works flawless.

    My idea for a workaround is to, if possible, set order priority with VBA after the form has been closed.

    I hope this explain my problem.

    /Roger

    Tuesday, September 10, 2013 8:09 AM
  • Hi Roger

    Thank you for the additional detail. It does seem odd...

    Just to make sure I'm doing the same things as you, could you provide the minimal code that inserts the text and unloads the form that reprodues the behavior, please? If there's a lot of stuff going on, please include comments so that we know how to adapt it to our system.


    Cindy Meister, VSTO/Word MVP, my blog

    Tuesday, September 10, 2013 9:12 AM
    Moderator
  • Now I'm a bit embarrassed. When I prepered an example of the code to send to you I didn't get the error, so what the ... differed this from my original document. It turned out that the problems was due to an autotext that was inserted into the document by code and this autotext was created and saved in the template before I rearranged the priority to my styles.

    So I deleted the autotext, once again set the priority on the styles in desired order, then created the autotext and then everything works as it should. Something in the autotext messed up the priority!

    So, thanks Cindy for your effort to helping me and I'm sorry for waisting your time.

    Regards,

    Roger

    Thursday, September 12, 2013 12:54 PM
  • Heh, welcome to my world :-) Sometimes it just helps to discuss it with someone who hasn't a clue about the project, to get a different point of view and make you go at it from a different angle.

    It's not the first time we've found that an AutoText (or BuildingBlock) is bringing unwanted styles information into a document and "messing things up". I'm keeping an unofficial list of that kind of thing, so I'm glad to have interacted with you.

    Good that things are working, now!


    Cindy Meister, VSTO/Word MVP, my blog

    • Marked as answer by RogerZen Friday, September 13, 2013 9:13 AM
    Thursday, September 12, 2013 5:18 PM
    Moderator