Using Word object to get "Available fomatting list" from the "Style and Formatting Pane"

Hi all,

Is there anyone know how to use MS word object to get the "Available fomatting" list (those formatting that is shown on the "Style and Formatting Pane") for a particular document

-Brian


Answer this question

Using Word object to get "Available fomatting list" from the "Style and Formatting Pane"

  • Rod_Kane

    Brian,

    Here's what you can do:

    Dim docStyle As Style
    Dim docStyles As Styles

    Set docStyles = ActiveDocument.Styles
    For Each docStyle In docStyles
    Debug.Print docStyle.NameLocal
    Debug.Print docStyle.InUse
    Next docStyle

    The thing to keep in mind is that there is no OM with a 1:1 correspondence to what you see in the functionality of the styles task pane. But, the data are all there. Loop through the styles and check the InUse property to know if it is being used. You should look at the other properties to get more info about each style.

    It is helpful to remember that this forum is mainly for issues that directly pertain to the Visual Studio Tools for Office tools per se. So you will be best served by posing this question to a forum or newsgroup wholly dedicated to application-specific issues such as this one. Here is a link to resources that will help you.:

    http://blogs.msdn.com/johnrdurant/archive/2005/12/16/word_developer_resources.aspx

    HTH!

    John.



  • Using Word object to get "Available fomatting list" from the "Style and Formatting Pane"