Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default problems closing workbook

I'm not certain, but it appears I've crated a conflict between my Workbook-level code and the module-level code. When I close the workbook using the "X", the "Enable Macros" / "Disable Macros" window displays...after 10 seconds; the duration of the timer. What can I do to eliminate the Macros window

Thanks

Kevi

The following code exists in Module1
Sub Auto_Open(
Application.OnTime Now + TimeValue("00:00:10"), "Close_Workbook
End Su
Sub Close_Workbook(
Application.DisplayAlerts = Fals
Application.Qui
End Su

The following code exists in ThisWorkbook
Sub Workbook_BeforeClose(Cancel As Boolean
ThisWorkbook.Saved = Tru
ThisWorkbook.Clos
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 473
Default problems closing workbook

Kevin wrote:
I'm not certain, but it appears I've crated a conflict between my Workbook-level code
and the module-level code.
When I close the workbook using the "X", the "Enable Macros" / "Disable Macros" window displays...after 10 seconds; the duration of the timer. What can I do to eliminate the Macros window?


The problem is that the OnTime event is not cancelled when you close the workbook
- only when you exit from Excel

Try this:

Module1:
Public ClosingTime As Date

Sub Auto_Open()
ClosingTime = Now + TimeValue("00:00:10")
Application.OnTime ClosingTime, "Close_Workbook"
End Sub
Sub Close_Workbook()
Application.DisplayAlerts = False
Application.Quit
End Sub

ThisWorkbook:
Sub Workbook_BeforeClose(Cancel As Boolean)
Application.OnTime ClosingTime, "Close_Workbook", schedule:=False
ThisWorkbook.Saved = True
ThisWorkbook.Close
End Sub


Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - reply in newsgroup

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default problems closing workbook

Thanks Bill. Works fine now.

----- Bill Manville wrote: -----

Kevin wrote:
I'm not certain, but it appears I've crated a conflict between my Workbook-level code
and the module-level code.
When I close the workbook using the "X", the "Enable Macros" / "Disable Macros" window displays...after 10 seconds; the duration of the timer. What can I do to eliminate the Macros window?


The problem is that the OnTime event is not cancelled when you close the workbook
- only when you exit from Excel

Try this:

Module1:
Public ClosingTime As Date

Sub Auto_Open()
ClosingTime = Now + TimeValue("00:00:10")
Application.OnTime ClosingTime, "Close_Workbook"
End Sub
Sub Close_Workbook()
Application.DisplayAlerts = False
Application.Quit
End Sub

ThisWorkbook:
Sub Workbook_BeforeClose(Cancel As Boolean)
Application.OnTime ClosingTime, "Close_Workbook", schedule:=False
ThisWorkbook.Saved = True
ThisWorkbook.Close
End Sub


Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - reply in newsgroup


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
Closing a workbook N1KO Excel Discussion (Misc queries) 0 February 12th 09 03:51 PM
Help with closing down a workbook?? Don Excel Worksheet Functions 1 May 9th 05 04:05 AM
prohibit closing a workbook Christophero Excel Discussion (Misc queries) 2 April 4th 05 05:54 PM
Closing Workbook without Saving Chris Gorham[_3_] Excel Programming 2 December 11th 03 12:17 AM
closing workbook Sam Dickins Excel Programming 1 November 27th 03 03:43 PM


All times are GMT +1. The time now is 06:19 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"