Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Can You Re-Create this problem?

Take 2 minutes and try the following. Let me know if you can you re-create
this problem:

1) Put this code in the ThisWorkbook module of a new blank Excel Workbook.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.Worksheets("Sheet2").Activate
End Sub


2) Save the workbook as Test1.xls
3) Close Excel.
4) Make a copy of Test1.xls and name it Test2.xls.
5) Open both Test1.xls and Test2.xls.
6) Click the Close ("X") button for Excel (the upper right hand corner of
the Excel window).


You will notice that neither workbook closes. What is that all about?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Can You Re-Create this problem?

Hi
same problem with Excel 2003 8no idea why). But the following works for
me:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Me.Worksheets("Tabelle2").Activate
Application.EnableEvents = False
Me.Close
Application.EnableEvents = True
End Sub

--
Regards
Frank Kabel
Frankfurt, Germany


John Camburn wrote:
Take 2 minutes and try the following. Let me know if you can you
re-create this problem:

1) Put this code in the ThisWorkbook module of a new blank Excel
Workbook.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.Worksheets("Sheet2").Activate
End Sub


2) Save the workbook as Test1.xls
3) Close Excel.
4) Make a copy of Test1.xls and name it Test2.xls.
5) Open both Test1.xls and Test2.xls.
6) Click the Close ("X") button for Excel (the upper right hand
corner of the Excel window).


You will notice that neither workbook closes. What is that all about?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Can You Re-Create this problem?

Thanks for confirming that I am not going insane!

I also appreciate the workaround. I had already tried wrapping the Activate
call with EnableEvents, but that didn't work. The Me.Close is a stroke of
simplistic genius. I still don't understand why it's necessary though.

Thanks again.

John


"Frank Kabel" wrote in message
...
Hi
same problem with Excel 2003 8no idea why). But the following works for
me:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Me.Worksheets("Tabelle2").Activate
Application.EnableEvents = False
Me.Close
Application.EnableEvents = True
End Sub

--
Regards
Frank Kabel
Frankfurt, Germany


John Camburn wrote:
Take 2 minutes and try the following. Let me know if you can you
re-create this problem:

1) Put this code in the ThisWorkbook module of a new blank Excel
Workbook.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.Worksheets("Sheet2").Activate
End Sub


2) Save the workbook as Test1.xls
3) Close Excel.
4) Make a copy of Test1.xls and name it Test2.xls.
5) Open both Test1.xls and Test2.xls.
6) Click the Close ("X") button for Excel (the upper right hand
corner of the Excel window).


You will notice that neither workbook closes. What is that all about?




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2003 Pivot Table Problem - Can No Longer Create Calculated Field Peter Van Eerde Excel Worksheet Functions 0 January 13th 10 12:56 AM
Create a macro to create excel line graph with coloured pointers anddata lables anuj datta Charts and Charting in Excel 1 September 30th 09 04:04 PM
How to create adress list so can mail merge and create labels? adecocq Excel Discussion (Misc queries) 2 October 25th 06 12:32 AM
Create dictionary of terms, create first time user site Solitaire Jane Austin New Users to Excel 1 January 19th 06 09:47 PM
Problem with using a macro to create a chart lopsided[_8_] Excel Programming 2 February 6th 04 10:50 AM


All times are GMT +1. The time now is 10:54 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"