How do I get excel to close completely after creating a macro in a personal workbook?

4

I am using Microsoft Excel 2007 and have several macros in my personal.xlsb workbook, which I use often, so it is very convenient that Excel opens them automatically when it starts. What I don't like is when I click on the "X" in the upper right corner of the window Excel does not exit when I close the last visible workbook. I think that this is because personal.xlsb is still open (though hidden). There are several other questions here on Superuser that have people remove personal.xlsb or move it so it doesn't open on startup (question 65297) or change settings to have only one window show in the taskbar (question 86989). (Sorry there are no hyperlinks--apparently I need more reputation to add additional hyperlinks.)

I would like to have personal.xlsb open when I open Excel, have each Excel window show in the taskbar but have Excel exit when I click the "X" on the last workbook that isn't personal.xlsb. Any thoughts on how to achieve this?

Greg B

Posted 2010-03-22T22:03:48.360

Reputation: 238

Answers

2

Create code for the Workbook.SheetDeactivate Event, that checks if
ActiveWorkbook.Sheets.Count =
(1 or 0, you'll have to play with this to see which works)

Then have it Close the Workbook if it's true.

Lance Roberts

Posted 2010-03-22T22:03:48.360

Reputation: 7 895

3

You need to go to the Excel options/advanced/display and uncheck Show all windows in the taskbar

Olga

Posted 2010-03-22T22:03:48.360

Reputation: 31

0

You can fix this problem without any code or special keystrokes by just opening any Excel document or creating a new one, and then closing it. Then on the remaining blank Excel workbook, under the View menu, unhide the file Personal.xlsb. Re-hide it and close the blank workbook. It will prompt you to save the Personal.xlsb, to which you say Yes, and the problem goes away.

Ray

Posted 2010-03-22T22:03:48.360

Reputation: 1

0

Other "workarounds" suggested (and explained more fully) here include:

  • hold down Shift as you click the red "X"
  • add 'Exit Excel' to your 'Quick Access Toolbar'
  • use Alt+F4 to close it.

kmote

Posted 2010-03-22T22:03:48.360

Reputation: 2 322

While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – Máté Juhász – 2015-11-04T05:32:59.713

1Thanks, @MátéJuhász. This post was back in my newbie days. Have updated. – kmote – 2015-11-04T15:47:21.170