When I open an Excel file from Finder and close the Excel window by Command+W. The active window remain Excel.

Is there a way to make Finder active window when I close Excel?

If I close the Excel window by Command+Q, the Finder become active but I prefer to keep Excel in memory.

  • Is this question targeted to Excel application only or a more general one? – dan May 4 '15 at 7:15
  • I was asked about general one. – ironsand May 4 '15 at 15:05
  • Then I advise you to specify correctly what you really need within your original question. This is where the information will stay. The comments are not here to stay. – dan May 5 '15 at 9:02

You can do this with Keyboard Maestro.
Create a macro group just for Excel, then create a macro that executes upon ⌘W which closes the window and switches focus to Finder.


| improve this answer | |
  • Thanks for answer. I installed the software. But I want to activate the last active window, not just Finder. Is there a way to configure like that? – ironsand May 3 '15 at 13:17
  • 1
    I found it! There is Activate Last Application. Thanks for your help! – ironsand May 3 '15 at 13:21
  • 2
    @ironsand It would possibly have been helpful if you had stated in your original question that you wanted the last active window and not Finder, as it says now. – oarfish May 3 '15 at 15:08
  • But this script will work even when there are more than one Excel window opened. – Mateusz Szlosek May 3 '15 at 16:56
  • @MateuszSzlosek This was not specified in the question. Should this be necessary, a simple if check for the frontmost application's window title would suffice. – grg May 3 '15 at 17:01

I'm not sure you can really have both…

Telling Excel to close a window doesn't tell Excel to quit. It doesn't actually tell it anything other than you closed a window. It sits there waiting for you to tell it what to do next; it can't guess what your next action is going to be.

Of course, if you Quit it, then it goes away & the last-used app will be frontmost.

Clicking the desktop is the quickest way to bring the Finder to the front.

| improve this answer | |
  • Thanks for your answer. If there is no way to accomplish what I want by default osx function. It's ok to install some application for it. – ironsand May 2 '15 at 17:12
  • It would have to be a mind-reader, to know what you wanted. If every time you closed a window, it jumped back to the Finder it would drive you mad in a day. – Tetsujin May 2 '15 at 17:41
  • What I want is, every time I close window make the application inactive. I don't think it requires mind-reader. – ironsand May 3 '15 at 5:50
  • 4
    For me - what OP is asking doesn't make sense. But: "Clicking the desktop is the quickest way to bring the Finder to the front." -> He can also +W -> +⇥TAB to quickly switch to last active app. – Mateusz Szlosek May 3 '15 at 11:00
  • @MateuszSzlosek i agree with his answer – Macmaniman May 3 '15 at 11:29

Update 1

Based on the comments made by ironsand to grgarside's answer. Step 6 should be changed to:

tell application "System Events" to set activeApp to name of application processes whose frontmost is true
if length of activeApp is not 0 then
    tell application (first item of activeApp) to activate
end if

My Answer to Posted Question

This can be done by creating a Service using the Automator application. However, you will not be able to use the the COMMAND+W key. I would suggest using the CONTROL+W key since Excel has not yet assigned this key to any function.

  1. Open the Automator Application and click on New Document.
  2. Select Service and click Choose.
  3. Select File->Save from Menus and save service as "Close and Activate Finder". You should see the following window. (Hint: "Open Image in a New Window" for a better view.)

enter image description here

  1. Drag "Close Excel Workbooks" to "Drag actions or files here to build your workflow" window. In the pop up window, click on "Don't Add".
  2. Drag "Run AppleScript" to "Drag actions or files here to build your workflow" window.
  3. Add the text line activate application "Finder" after the text line (* Your script goes here *).

The window should now appear as shown below.

enter image description here

  1. Under "Service receives selected" choose "no input".
  2. Change "any application" to "Other...". In the pop-up window, choose "Microsoft Excel". The window should now appear as shown below.

enter image description here

  1. Select File->Save from Menus.
  2. Select Automator->Services->Services Preferences... from the Menus. Find "Close and Activate Finder" at the bottom of the available services.
  3. Click twice on the word "none" to the right of "Close and Active Finder". Enter the CONTROL-W key. The window should now appear as shown below.

enter image description here

  1. Quit System Preferences and Automator applications.

  2. Test using the Finder and Excel applications.

| improve this answer | |

What is the point of having Excel running without a document open? So that it opens the next document faster? If so, then make sure you have lots of memory (RAM) and then quit using CMD-Q instead of closing the window using CMD-W.

When you have lots of RAM, modern operating systems cache or preserve most or all of the application in memory for when you need it next. This make starting the application next time super quick.

You can see this when you startup your computer. Any large application you start takes a while to come up. If you close it and then re-open it, it is very quick. This is because most of it was still in memory, kept close at hand, so to speak.

But, should you load an application that needs lots of memory, the system may remove Excel from its cache and the next time Excel needs to startup it will be slower…

| improve this answer | |

+W, +H is closing the active window and then switching to the previously active application with most decent applications.

Most of the time this will be much more efficient than a switch to the Finder because we tend to go back to what was just interrupted before.

| improve this answer | |

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .