Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Microsoft Word keyboard shortcut to close the sidebar Apps
Microsoft Word 2011 does not, as far as I can tell, offer a means of assigning a keyboard shortcut to close the sidebar. The AppleScript described here provides that functionality, and sets a keyboard shortcut that will trigger it.

Name the following Applescript "MicrosoftWordCloseSidebar\mosH.scpt" (notice the reversed slash) and save it in ~/Library/Application Support/Microsoft/Office/Word Script Menu Items:
do shell script "osascript -e '
tell application \"System Events\" to tell process \"Microsoft Word\"
 	set {frontmost, itemFound} to {true, false}
 	repeat with w in windows
 		tell w to repeat with g in groups
 			tell g to repeat with c in checkboxes
 				tell c to if value of its attribute \"AXHelp\" = \"Close the Sidebar\" then
 					set itemFound to true
 					click
 					exit repeat
 				end if
 			end repeat
 			if itemFound then exit repeat
 		end repeat
 		if itemFound then exit repeat
 	end repeat
end tell
' >/dev/null 2>&1 &"
When you press Command-Option-Shift-H, the close button of the sidebar is clicked, and the sidebar closes. The keyboard shortcut comes from the "mosH" part of the Applescript name (m=Command, o=Option, s=Shift, H=the letter H). That shortcut was chosen to complement the existing shortcut to open the Find/Replace Sidebar (Command-Shift-H) and may be altered to suit a particular user's needs. The script is constructed as a background osascript to get around a problem that occurs when trying to GUI-script Microsoft Word from its script menu.
    •    
  • Currently 3.29 / 5
  You rated: 1 / 5 (7 votes cast)
 
[6,853 views]  

Microsoft Word keyboard shortcut to close the sidebar | 12 comments | Create New Account
Click here to return to the 'Microsoft Word keyboard shortcut to close the sidebar' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Microsoft Word keyboard shortcut to close the sidebar
Authored by: kikjou on Feb 27, '13 07:55:19AM

Why not simply make a keyboard shortcut in System Preferences -> Keyboard? I tested it with Microsoft Word in Lion and Mountain Lion.



[ Reply to This | # ]
Microsoft Word keyboard shortcut to close the sidebar
Authored by: llee on Feb 27, '13 08:49:39AM

You might have to press the shortcut twice to close the sidebar, unless you had a different shortcut for each item in the sidebar sub menu, right?



[ Reply to This | # ]
Microsoft Word keyboard shortcut to close the sidebar
Authored by: schuyler on Feb 28, '13 06:15:32AM

Yes, a separate shortcut would have to be assigned to each of the sidebar menu items (four in my version of Word). The current script generically closes the sidebar independent of which specific sidebar is open.



[ Reply to This | # ]
Microsoft Word keyboard shortcut to close the sidebar
Authored by: maelcum on Mar 03, '13 12:35:11PM

Hi,

Could you elaborate on this? How do you define the shortcut?

Thanks

mael



[ Reply to This | # ]
Microsoft Word keyboard shortcut to close the sidebar
Authored by: schuyler on Mar 04, '13 10:57:41PM

Are you referring to the keyboard shortcut made through System Preferences, or the one made through the special naming of the Applescript saved in ~/Library/Application Support/Microsoft/Office/Word Script Menu Items?



[ Reply to This | # ]
Microsoft Word keyboard shortcut to close the sidebar
Authored by: schuyler on Mar 03, '13 10:41:47AM

Correction: the existing Microsoft Word shortcut to open the Find/Replace Sidebar is Command-Shift-H (not Command-Option-H).



[ Reply to This | # ]
Microsoft Word keyboard shortcut to close the sidebar
Authored by: Heathlynn on Jun 05, '13 12:53:47PM

This holds great promise for me, but after navigating to the Library/Application Support/Microsoft folder, I don't find the other subfolders you name. What do you suggest?



[ Reply to This | # ]
Microsoft Word keyboard shortcut to close the sidebar
Authored by: schuyler on Jun 07, '13 06:39:03AM
First, be sure you are navigating to the proper folder. You do not want: [Macintosh hard drive] > Library > Application Support > Microsoft, which is where you may have been navigating to. You do want: [Macintosh hard drive] > Users > [your home folder] > Library > Application Support > Microsoft > Office > Word Script Menu Items.*

Second, if you are missing the final folder named Word Script Menu Items, then navigate to [Macintosh hard drive] > Users > [your home folder] > Library > Application Support > Microsoft > Office and create a folder named Word Script Menu Items in the Office folder. Save the Applescript in the Word Script Menu Items folder.

You should now have a working keyboard shortcut.

*Note: The tilde ~ in ~/Library/Application Support/Microsoft/Office/Word Script Menu Items in the hint is shorthand for [Macintosh hard drive] > Users > [your home folder].
Edited on Jun 07, '13 06:41:54AM by schuyler


[ Reply to This | # ]
Microsoft Word keyboard shortcut to close the sidebar
Authored by: Heathlynn on Jun 07, '13 07:12:19AM

Curious and curiouser: I have no LIBRARY folder subordinate to my USERNAME folder.



[ Reply to This | # ]
Microsoft Word keyboard shortcut to close the sidebar
Authored by: schuyler on Jun 07, '13 07:49:25AM
The user Library folder is hidden in OS X Lion and Mountain Lion. A simple way to navigate to it is to hold down the Option key while clicking on the "Go" menu item in the Finder, then click on "Library". Several other ways of temporarily or permanently unhiding the user Library folder are described here: Permanently Unhide Library

[ Reply to This | # ]
Microsoft Word keyboard shortcut to close the sidebar
Authored by: schuyler on Jun 14, '13 06:42:28AM
In response to the previous commenter's problems navigating to/creating the "Word Script Menu Items" folder, the following two-line Applescript opens the "Word Script Menu Items" folder (creating it if it doesn't already exist). The keyboard shortcut Applescript can then be dragged into the open folder, and the shortcut should then work.

set f to ("" & (path to home folder) & "Library:Application Support:Microsoft:Office:Word Script Menu Items")'s POSIX path's quoted form
do shell script "mkdir -p " & f & "; open " & f


[ Reply to This | # ]
Love it--used Keyboard Maestro for easy access
Authored by: ajg23 on Jun 21, '14 01:39:05PM

This is fantastic. Put the code in a Keyboard Maestro macro in a group activated only when Word in front. Looks like this: https://www.evernote.com/shard/s2/sh/7076c005-2c93-4984-8a15-fe0253f47cec/dc21bff88e995470d3e5c8728f627f6b

[sorry about the long link--don't see how to include a pic here :)]

I like that I can use this also to close the reviewing pane if I've added a "Note" for quick access to additional information about a part of a document (the sidebar gets opened because I work in draft mode).

Thank you very much for making the script!



[ Reply to This | # ]