none
How to set style of complete word document RRS feed

  • Question

  • Hi,

    In word, I can change style of the document by clicking Change Style--> Style Set (please see attachment). There I can choose between various style sets like "Traditional,Fancy, elegant.." etc.

    The style set provided here are without any doubt give a professional look to the document and are pre-configured.

    - How can I use a style set for my word document?

    - Another thing is that I do not want to use style strings because we will be using our library on PC with different word languages. How to achieve this?

    A Sinnpet of my code:

    Word.Application mApplication = new Microsoft.Office.Interop.Word.Application();
    
    Word.Document mDocument = mApplication.Documents.Add(ref MISSING, ref MISSING, ref MISSING, ref MISSING);
    
    mDocuemnt.???? (to set mentioned style)

    Thanks in advance.

    Regards

    Ricky



    Friday, August 9, 2013 10:54 AM

Answers

  • Hi Ricky

    Sorry, from your description it sounded like you needed to learn more about styles. From the sound of it, you actually do need to learn a lot about styles before you start... Style sets are not exposed to the API, beyond you being able to apply one, or save a current set of styles as one. Style sets are defined in the XML that make up the document package.

    <<How can I use a style set for my word document?>>

    expression.ApplyQuickStyleSet2(Style)

    expression An expression that returns a Document object.

    <<Another thing is that I do not want to use style strings because we will be using our library on PC with different word languages. How to achieve this?>>

    You have to work with strings, at some level. You have no choice - that's what identifies a style in Word. You may need a resource that lists the various names for a specific style, to which you assign an internal "id" in order to look it up. That's usually how multi-language strings are handled. But you're going to have to do some careful planning if documents are going to be shared between regions with different languages.


    Cindy Meister, VSTO/Word MVP, my blog

    • Marked as answer by ricky_CSharp Friday, August 9, 2013 1:22 PM
    Friday, August 9, 2013 12:22 PM
    Moderator

All replies