none
VBA - How to change style's name RRS feed

  • Question

  • Hi,

    I have the same Word Template that can be used in Language A and in Language B.

    For a language A user all the custom styles names are in language A; for a language B user all the custom styles names are in language B.

    Since a language A user can open a document generated by a language B user, I would like that when the document B is opened all the custom styles names will be renamed with language A names.

    I can I easily perform that since I don't see a Name Property in the Style Object.

    Nota Bene: I define the custom syles, but the users can change their properties.

    Thanks, Lauro

    Saturday, February 10, 2018 10:12 AM

All replies

  • Hello Lauro2,

    >>I would like that when the document B is opened all the custom styles names will be renamed with language A names.

    As far as I know, Microsoft Word application does not provide such function. It could only change fixed built-in style's name but not for dynamic custom style's name. It does not define an standard to convert any word from an language to another language.

    For renaming the name, you could try to right click the style and select Modify to rename its name or you could try to set the NameLocal property to rename it.

    For instance.

    Sub test()
    Dim sty As Style
    For Each sty In ThisDocument.Styles
    If sty.BuiltIn = False Then
    sty.NameLocal = "A new style name"
    Exit For
    End If
    Next sty
    End Sub

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Monday, February 12, 2018 5:46 AM