Classic behaviour for "Styles" task pane (setfocus to it)

一般討論 Classic behaviour for "Styles" task pane (setfocus to it)

  • 2012年4月16日 下午 12:12
     
      包含代碼

    Hi all,

    In previous versions (2003) of word, when I let show the "Styles"- task pane,
    then it got immediatelly the focus and I could use the kayboard to select the
    appropriate style for the selected paragraph.
    In word 2010 I have to press n-times [F6] before I come to that pane with my focus :(((

    So I wrote this little macro [say 2], that makes it work like before :

    Function getCommandbarIndex(aName As String) As Long
        Dim vCb1 As CommandBar
        
        getCommandbarIndex = -1
        
        For Each vCb1 In Application.CommandBars
            If LCase(vCb1.Name) = LCase(aName) Then
               getCommandbarIndex = vCb1.Index
               Exit Function
            End If
        Next vCb1
    
    End Function
    
    Sub showhideFormattingPane()
        Dim vLo1 As Long
        Dim vCbCt1 As CommandBarControl
        
        DoEvents
        
        If Application.TaskPanes(wdTaskPaneFormatting).Visible Then
           Application.TaskPanes(wdTaskPaneFormatting).Visible = False
        Else
           Application.TaskPanes(wdTaskPaneFormatting).Visible = True
           
           vLo1 = getCommandbarIndex("Styles")
           CommandBars(vLo1).Controls(1).SetFocus
           
        End If
    End Sub
    

    If you assign a keyboard shortcut to the second macro, then u can show the formatting pane and it will have the focus :)
    I've assigned the shortcut [ALT]+[V] (for "Vorlagen", this is german ;-)

    But that way has a disadvantage - while the task pane has the focus, word stops processing shortcuts  8-0
    So if you want to cancel the formatting at all, u cannot press [ALT]+[V] again to hide the task pane.
    U have to press [ESC] at first, then u can press [ALT]+[V] again to hide it....

    If u have suggestions or found some bugs, then please post an anwser :)

    Thank u and
    Best regards
    dp.

所有回覆

  • 2012年4月16日 下午 11:12
     
     
    Actually, it will be easier to apply a style via the Apply Styles pane (Ctrl+Shift+S). Once the pane has been displayed, you can type in a style name, or you can press the down arrow to display the list of styles. Pressing Enter applies the selected style to the selection.
     
    To set the focus back to the pane, press Ctrl+Shift+S again.

    Stefan Blom, Microsoft Word MVP
  • 2012年4月17日 上午 07:44
     
     

    Hi Stefan,

    Thank u for that helpful hint :)
    I will try this...

    Best regards,
    dp.

  • 2012年4月17日 下午 06:30
     
     
    "Doubting Pearl" wrote in message news:b9c5fa31-5a4c-4509-bb8a-744f966e6781@communitybridge.codeplex.com...
    Hi Stefan,
     
    Thank u for that helpful hint :)
    I will try this...
     
     
    You are welcome.

    Stefan Blom, Microsoft Word MVP