Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Jan 2004
    Location
    Mount Prospect, Illinois
    Posts
    142
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Word XP Task Pains, er Panes (XP/2002)

    Is there any way to control the settings in the task panes via VBA?
    specifically (so far at least):
    1) "Distinguish Style Source" in Reveal Formatting -- you'd think this would be in Application.Options somewhere
    2) Showing "Custom" styles in the Styles and Formatting -- this would be nice to be able to program, so that users didn't use standard styles that aren't part of the corporate style.

    Thanks,
    Joel

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

    Re: Word XP Task Pains, er Panes (XP/2002)

    Hi Joel,

    Steve Hudson has written a good article on task panes: http://www.geocities.com/word_heretic/TaskPanesVBA6.zip.

    I think you may find something about your second question in there (though much of the stuff doesn't work well in Word2002, and even more doesn't work in Word2003).

    To set the visibility of some style:
    <pre> ActiveDocument.Styles("myStyle").Visibility = True</pre>

    If you change something that has effect on the "Styles and Formatting" task pane, you need to update it so the changes become visible.
    A reliable way to do so seems to be
    <pre> Options.FormatScanning = Not (Options.FormatScanning)
    Options.FormatScanning = Not (Options.FormatScanning)</pre>


    Re your first question, I haven't seen any VBA code yet.

    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16> Klaus

  3. #3
    2 Star Lounger
    Join Date
    Jan 2004
    Location
    Mount Prospect, Illinois
    Posts
    142
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word XP Task Pains, er Panes (XP/2002)

    I've looked at that Task Pane reference, very handy.
    However, it doesn't seem to be working for the Formatting pane:

    The code to change which class of styles show (all, avail, in use) is
    <pre>Public Sub StylesAndFormattingFocus( _
    Optional ShowFont As Boolean = True, _
    Optional ShowClear As Boolean = False, _
    Optional ShowNumbering As Boolean = True, _
    Optional ShowParagraph As Boolean = True, _
    Optional FilterStyle As WdShowFilter = wdShowFilterFormattingAvailable)

    'Ensure the S&F Task Pane is showing

    With CommandBars("Task Pane")
    If .Controls(1).Caption <> "Styles and Formatting" _
    Then CommandBars.FindControl(ID:=5757).Execute
    End With

    With ActiveDocument
    .FormattingShowFont = ShowFont
    .FormattingShowClear = ShowClear
    .FormattingShowNumbering = ShowNumbering
    .FormattingShowParagraph = ShowParagraph
    .FormattingShowFilter = FilterStyle
    End With
    StylesAndFormattingRefresh
    End Sub

    Public Sub StylesAndFormattingRefresh()
    SendKeys "{Enter}"
    Dialogs(wdDialogFormatStylesCustom).Execute
    End Sub</pre>


    But no matter what I use on the input to the above function, i.e.
    StylesAndFormattingFocus wdShowFilterStylesAll

    all I get is "Custom" on the setting in the task pane.

    I've tried deleting the Data key, and that's not it.
    Anyone had any luck with these settings?

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

    Re: Word XP Task Pains, er Panes (XP/2002)

    Steve's code works for me (Word2002). I haven't tested it in Word2003.

    The task pane does display "Custom", but the styles shown correspond to the filter you have set.
    Considering how buggy the rest of the VBA for the "Styles and formatting" pane is (such as the .Visible property for styles), that's qite something <img src=/S/wink.gif border=0 alt=wink width=15 height=15>.
    <img src=/S/crossfingers.gif border=0 alt=crossfingers width=17 height=16> Perhaps the stuff will be fixed in Word2020?
    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16> 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
  •