Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Mar 2003
    Location
    Elkins Park, Pennsylvania, USA
    Posts
    325
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Styles Task Pane thru VBA (Word XP)

    Greetings.
    Again, I'm at a loss when trying to reconcile Word's help file with what I actually get when writing code.

    What I would like to do is to set the styles that are displayed in the Styles and Formatting task pane. I'm the technoid for a word processing center, and the users are frustrated that very common styles such as Caption and the TOC styles are not automatically displayed in the Style pane. I figured I could quickly write (read: record and modify) some code that would set up the styles that should be displayed for a document. I'm pasting the code I ended up with below.

    Sub SetStylePane()
    With ActiveDocument
    .Styles("Caption").Visibility = True
    .Styles("Footnote Reference").Visibility = True
    .Styles("Footnote Text").Visibility = True
    .Styles("Normal").Visibility = True
    .Styles("TOC 1").Visibility = True
    .Styles("TOC 2").Visibility = True
    .Styles("TOC 3").Visibility = True
    .Styles("TOC 4").Visibility = True
    .Styles("TOC 5").Visibility = True
    .Styles("TOC 6").Visibility = True
    .Styles("TOC 7").Visibility = True
    .Styles("TOC 8").Visibility = True
    .Styles("TOC 9").Visibility = True
    End With
    End Sub

    However, whether I run what I whittled down (as shown above) or the actual macro that was recorded (which, interestingly, had the values set to "False" after recording it) nothing happens! Obviously, I must be missing some piece of knowledge when it comes to manipulating that area of Word, and I'm hoping someone here can give me some guidance.

    Thanks in advance.
    <font face="Comic Sans MS">That's what you do in a herd; you look out for each other!</font face=comic> - Mike

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: Styles Task Pane thru VBA (Word XP)

    There is a lot of code at Styles and Formatting in Word's Task Panes VBA Reference on the Word MVP site. Look for StylesAndFormattingCustomMine; you'll have to copy some other code too.

    Note 1: there is a typo in StylesAndFormattingCustomMine: Visible should be Visibility (twice).
    Note 2: I can't get this code to work consistently; sometimes is works as intended, sometimes it does something else and sometimes it does nothing.

  3. #3
    5 Star Lounger
    Join Date
    May 2001
    Location
    Stuttgart, Baden-W, Germany
    Posts
    931
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Styles Task Pane thru VBA (Word XP)

    And it seems to be messed up even worse in Word2003...

    <img src=/S/frown.gif border=0 alt=frown width=15 height=15> Klaus

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •