Crash on ActiveWindow.Close

M

Misbah

Hi,

Excel 2007 application crahses, when I click one of my graphic buttons (on
my Excel front-end) to call an assigned macro that is being used with the
intent to close the workbook and exit from Excel. I have tried using
ActiveWindow.Close, ActiveWorkbook.Close and ThisWorkbook.Close; but all of
them result in crashing excel.

When I call the same macro somewhere else (and not at the click of graphics
button), it closes the active workbook fine (without falling over). The
problem is consistent whenever, I call that macro graphics button click
event. It was not the case with earlier versions (such as Excel 2003).

Certainly, the plan is not to use Excel form buttons or Visual Basic buttons
(as alternatives) to proceed with the task. Graphics buttons provide great
look and feel to end-users (that is why, I am persisting on these buttons).

Is there a limitation in using graphics buttons in such a way (that I am
using)? I have not found much in the Internet. Could anyone please help me in
this regard? I would be obliged.

Regards,
Misbah
 
J

Jim Rech

I haven't tried to reproduce your problem but I have found on occasion that
having a macro close its own workbook, etc, can be dicey.

Sometimes I find that 'disassociating' the close from the event that
triggers it helps, using OnTime:

Sub ClickHandler()
Application.OnTime Now, "CloseMe"
End Sub

Sub CloseMe()
ThisWorkbook.Close False
End Sub


--
Jim
| Hi,
|
| Excel 2007 application crahses, when I click one of my graphic buttons (on
| my Excel front-end) to call an assigned macro that is being used with the
| intent to close the workbook and exit from Excel. I have tried using
| ActiveWindow.Close, ActiveWorkbook.Close and ThisWorkbook.Close; but all
of
| them result in crashing excel.
|
| When I call the same macro somewhere else (and not at the click of
graphics
| button), it closes the active workbook fine (without falling over). The
| problem is consistent whenever, I call that macro graphics button click
| event. It was not the case with earlier versions (such as Excel 2003).
|
| Certainly, the plan is not to use Excel form buttons or Visual Basic
buttons
| (as alternatives) to proceed with the task. Graphics buttons provide great
| look and feel to end-users (that is why, I am persisting on these
buttons).
|
| Is there a limitation in using graphics buttons in such a way (that I am
| using)? I have not found much in the Internet. Could anyone please help me
in
| this regard? I would be obliged.
|
| Regards,
| Misbah
 
R

Ron de Bruin

I report this bug this week
When you use close code and assign the macro to a picture in 2007 Excel crash

But if there is also Office 2003 installed on the machine there is no problem

Use a normal Forms or ActiveX button to avoid the problem
 
M

Misbah

Thanks a lot for your reply, Jim. It has certainly helped me. It is always
frustrating, when you don't find much help from the available resource(s) and
this always leads you to stray around. Thank a lot, again.

In addition ot this, I am a bit curious in terms of implementation concept.
Excel 2003 does not have any problem with ActiveWindow.Close behind the shape
click event; but Excel 2007 falls over. What can be the significant
(conceptual) reason behind this change? Is there a change (difference) on
Shape object's DOM (Document Object Model) in Excel 2007 from that of Excel
2003? Thanks again.

Regards,
Misbah
 
B

Buzz Mason

Hi Jim,
EXCELLENT work around... I'd just posted a similar issue then foud your
reply to this post. It works a treat...
Really can't understand why there is so much differance between 2003 and
2007 but with experts like you around...
Thanks again
Cheers
 
G

Gary Keramidas

that's probably why code in excel 2007 runs slower, it crashes if it runs too
fast.

they missed this operation with their built in "slow down" , so you have to
introduce a timer to wait a second so it can think about what it needs to do.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top