View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Rech[_2_] Jim Rech[_2_] is offline
external usenet poster
 
Posts: 533
Default Crash on ActiveWindow.Close

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
"Misbah" wrote in message
...
| 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