Results 1 to 4 of 4
  1. #1
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Australia
    Posts
    676
    Thanks
    28
    Thanked 2 Times in 2 Posts
    I use a macro with the following code to attach a template to documents.

    With ActiveDocument
    .UpdateStylesOnOpen = True
    .AttachedTemplate = _"C:\[template filename]"
    End With

    1. Is it possible to include the "StyleApplyPane" command in the macro, so that the Apply Styles pane is opened automatically when the macro is used?

    2. Alternatively, is it possible to configure Word so that the Apply Styles pane is opened automatically when any document is opened, or even when Word is started?

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    [quote name='Murgatroyd' post='794180' date='20-Sep-2009 17:21']1. Is it possible to include the "StyleApplyPane" command in the macro, so that the Apply Styles pane is opened automatically when the macro is used?

    2. Alternatively, is it possible to configure Word so that the Apply Styles pane is opened automatically when any document is opened, or even when Word is started?[/quote]
    Try something like:

    Code:
    Application.TaskPanes(wdTaskPaneApplyStyles).Visible = True
    See: TaskPanes Collection [Word 2007 Developer Reference] and related pages.

  3. #3
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts
    It looks like the Word command "FormattingPane" will toggle the appearance/non-appearance of the Styles and Formatting pane, so code like:
    Code:
    Application.Run "FormattingPane"
    should work - bear in mind that it's a toggle, though.
    [EDIT #1: the code posted by Jefferson is clearly better, since it isn't a toggle]

    [EDIT #2: "Application.TaskPanes(wdTaskPaneApplyStyles).Visib le = True" won't work in versions of Word prior to Word 2007. For earlier versions, try: "Application.TaskPanes(wdTaskPaneFormatting).Visibl e = True"]

    To force the pane to appear whenever any document is opened, you could put that same line of code in an application-level DocumentOpen event procedure in a global add-in. For some info on how to set up application-level event procedures, see the Word VBA Help topics: "Using Events with the Application Object", and "DocumentOpen Event".

    Gary

  4. #4
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Australia
    Posts
    676
    Thanks
    28
    Thanked 2 Times in 2 Posts
    Thank you both for your helpful replies.

Posting Permissions

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