Consulting

Results 1 to 5 of 5

Thread: MS Word, activate the Selection and Visibility Pane from within VBA code

  1. #1
    VBAX Newbie
    Joined
    Apr 2019
    Posts
    3
    Location

    MS Word, activate the Selection and Visibility Pane from within VBA code

    Dear Forum,

    my goal is to activate (open / switch on / enable) the "Selection and Visibility Pane" from within VBA code (Word macro).

    What is the "Selection and Visibility Pane"? This is part of Microsoft Word GUI. This tool is meant for working with objects in your document, particularly shapes and images. To use the tool, display the Page Layout tab of the ribbon and click the Selection Pane tool in the Arrange group. The pane appears at the right side of the document. (The Selection Pane tool is a toggle; clicking it a second time hides the pane.)

    What I already tried to do prior to asking a question here, was searching the following resources:

    https://docs.microsoft.com/en-us/off...cation.dialogs
    https://docs.microsoft.com/en-us/off...word.taskpanes

    Without a hit till now. I can't find any hint, how this pane is named or where to search for it.

    My MS Word: 2010 Professional Plus
    My operating system: Windows 7 Enterprise

    Kind regards, mslonik

  2. #2
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Quote Originally Posted by mslonik View Post
    my goal is to activate (open / switch on / enable) the "Selection and Visibility Pane" from within VBA code (Word macro).
    Why, as in what is the purpose of doing this?
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    VBAX Newbie
    Joined
    Apr 2019
    Posts
    3
    Location
    I have two keyboards connected to my Windows operating PC at the same time: the first keyboard (black) is used as "ordinary keyboard", the second (grey) runs as "macro keyboard". For almost all keys of the "macro keyboards" I have assigned macros. The macros are specific for Microsoft Word and written in AHK (Auto Hotkey).

    There are 3 levels how can I define macros for MS Word using AHK:
    a. repeat basic sequence of keys which are pressed to run specific function,
    b. define specific shortcut for a Word function,
    c. call COM function of MS Word.

    The "c" version is at most reliable, elegant and convenient. If I have VBA code, I can quite easily translate it to AHK. So I've thought this is the right forum to ask such a question.

    So to sum-up: I'like to have a key at "macro keyboard", which enables / disables view of the "Selection and Visibility Pane" just for my convenience, to apply AHK macro.

    I didn't think it could be a challenge.

    Kind regards, mslonik
    Last edited by mslonik; 04-02-2019 at 06:33 AM.

  4. #4
    VBAX Newbie
    Joined
    Apr 2019
    Posts
    3
    Location
    Finally I was able to figure it out:

    CommandBars("Selection and Visibility").Visible = True
    CommandBars("Selection and Visibility").Visible = False
    do a trick.

    Kind regards, mslonik

  5. #5
    VBAX Regular DaveM's Avatar
    Joined
    Mar 2022
    Posts
    10
    Location
    Hello mslonik,

    I was also trying to find a way to pop up the Selection and Visibility pane while in the process of building and grouping some shapes on screen via vba. I found your solution, but found that on first running the macro an error would occur on the first commandbars command.

    I found the following suggestion by John Wilson on the StackOverflow site from 2014:

    If Not CommandBars.GetPressedMso("SelectionPane") Then CommandBars.ExecuteMso("SelectionPane")

    This seemed to cure the first run failures.

    Dave

Posting Permissions

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