Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Command works from debug but not normally

I'm a problem closing a workbook without saving it. I'm closing another
workbook, then the current workbook with the following code in Private Sub
workbook_close():

Workbooks("real1.xls").Close False
Me.Close False

When I step through the code or run the code from the debug toolbar this
works. But when I use File Exit or the X, it asks whether or not I want to
save both files. I don't want to save either. What am I doing wrong?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Command works from debug but not normally

Are you disabling events before you try to close the file with the code?

If no, then when that me.close line executes, it'll fire the
workbook_beforeClose event again (you meant _beforeclose, right???)

application.enableevents = false
Workbooks("real1.xls").Close False
Me.saved = true 'this will stop the "save?" prompt
'if you closed it, then the procedure would stop at that line
'(when the Me closes)
'and never get to this next line.
application.enableevents = true


Merlynsdad wrote:

I'm a problem closing a workbook without saving it. I'm closing another
workbook, then the current workbook with the following code in Private Sub
workbook_close():

Workbooks("real1.xls").Close False
Me.Close False

When I step through the code or run the code from the debug toolbar this
works. But when I use File Exit or the X, it asks whether or not I want to
save both files. I don't want to save either. What am I doing wrong?


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Command works from debug but not normally

The enableevents=false stops it from asking if I want to save the "real1.xls"
file, but I'm still getting a prompt asking if I want to save the
activeworkbook (mgrquery.xls) even with the me.saved=true. I need to kill
that prompt as well. And yes, I meant "beforeclose". Thanks.

"Dave Peterson" wrote:

Are you disabling events before you try to close the file with the code?

If no, then when that me.close line executes, it'll fire the
workbook_beforeClose event again (you meant _beforeclose, right???)

application.enableevents = false
Workbooks("real1.xls").Close False
Me.saved = true 'this will stop the "save?" prompt
'if you closed it, then the procedure would stop at that line
'(when the Me closes)
'and never get to this next line.
application.enableevents = true


Merlynsdad wrote:

I'm a problem closing a workbook without saving it. I'm closing another
workbook, then the current workbook with the following code in Private Sub
workbook_close():

Workbooks("real1.xls").Close False
Me.Close False

When I step through the code or run the code from the debug toolbar this
works. But when I use File Exit or the X, it asks whether or not I want to
save both files. I don't want to save either. What am I doing wrong?


--

Dave Peterson
.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Command works from debug but not normally

The enableevents line doesn't suppress the prompt for reall.xls, that's what the
line:
Workbooks("real1.xls").Close savechanges:=False
line does.

Are you making any other changes to the workbook that holds the code
(mgrquery.xls) after that line?

I don't work with Queries to know, but guessing by the name, maybe it's a query
problem????

Merlynsdad wrote:

The enableevents=false stops it from asking if I want to save the "real1.xls"
file, but I'm still getting a prompt asking if I want to save the
activeworkbook (mgrquery.xls) even with the me.saved=true. I need to kill
that prompt as well. And yes, I meant "beforeclose". Thanks.

"Dave Peterson" wrote:

Are you disabling events before you try to close the file with the code?

If no, then when that me.close line executes, it'll fire the
workbook_beforeClose event again (you meant _beforeclose, right???)

application.enableevents = false
Workbooks("real1.xls").Close False
Me.saved = true 'this will stop the "save?" prompt
'if you closed it, then the procedure would stop at that line
'(when the Me closes)
'and never get to this next line.
application.enableevents = true


Merlynsdad wrote:

I'm a problem closing a workbook without saving it. I'm closing another
workbook, then the current workbook with the following code in Private Sub
workbook_close():

Workbooks("real1.xls").Close False
Me.Close False

When I step through the code or run the code from the debug toolbar this
works. But when I use File Exit or the X, it asks whether or not I want to
save both files. I don't want to save either. What am I doing wrong?


--

Dave Peterson
.


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Command works from debug but not normally

I solved my own problem. I was exiting the file but not Excel, so I added

application.displayalerts=false
application.quit

and now no matter how my users exit the file they won't see prompts asking
if they want to save. Thanks for the previous help.

"Merlynsdad" wrote:

The enableevents=false stops it from asking if I want to save the "real1.xls"
file, but I'm still getting a prompt asking if I want to save the
activeworkbook (mgrquery.xls) even with the me.saved=true. I need to kill
that prompt as well. And yes, I meant "beforeclose". Thanks.

"Dave Peterson" wrote:

Are you disabling events before you try to close the file with the code?

If no, then when that me.close line executes, it'll fire the
workbook_beforeClose event again (you meant _beforeclose, right???)

application.enableevents = false
Workbooks("real1.xls").Close False
Me.saved = true 'this will stop the "save?" prompt
'if you closed it, then the procedure would stop at that line
'(when the Me closes)
'and never get to this next line.
application.enableevents = true


Merlynsdad wrote:

I'm a problem closing a workbook without saving it. I'm closing another
workbook, then the current workbook with the following code in Private Sub
workbook_close():

Workbooks("real1.xls").Close False
Me.Close False

When I step through the code or run the code from the debug toolbar this
works. But when I use File Exit or the X, it asks whether or not I want to
save both files. I don't want to save either. What am I doing wrong?


--

Dave Peterson
.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Command works from debug but not normally

What happens if they have other workbooks open?

Do you really want to try to force them to quit?

(That never seemed fair to me (a typical user).)

Merlynsdad wrote:

I solved my own problem. I was exiting the file but not Excel, so I added

application.displayalerts=false
application.quit

and now no matter how my users exit the file they won't see prompts asking
if they want to save. Thanks for the previous help.

"Merlynsdad" wrote:

The enableevents=false stops it from asking if I want to save the "real1.xls"
file, but I'm still getting a prompt asking if I want to save the
activeworkbook (mgrquery.xls) even with the me.saved=true. I need to kill
that prompt as well. And yes, I meant "beforeclose". Thanks.

"Dave Peterson" wrote:

Are you disabling events before you try to close the file with the code?

If no, then when that me.close line executes, it'll fire the
workbook_beforeClose event again (you meant _beforeclose, right???)

application.enableevents = false
Workbooks("real1.xls").Close False
Me.saved = true 'this will stop the "save?" prompt
'if you closed it, then the procedure would stop at that line
'(when the Me closes)
'and never get to this next line.
application.enableevents = true


Merlynsdad wrote:

I'm a problem closing a workbook without saving it. I'm closing another
workbook, then the current workbook with the following code in Private Sub
workbook_close():

Workbooks("real1.xls").Close False
Me.Close False

When I step through the code or run the code from the debug toolbar this
works. But when I use File Exit or the X, it asks whether or not I want to
save both files. I don't want to save either. What am I doing wrong?

--

Dave Peterson
.


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Command works from debug but not normally

This is a re-write of the only Excel program they normally use, so dumping
them out shouldn't be a problem. Most of their stuff is custom built. Thanks
for the help.

"Dave Peterson" wrote:

What happens if they have other workbooks open?

Do you really want to try to force them to quit?

(That never seemed fair to me (a typical user).)

Merlynsdad wrote:

I solved my own problem. I was exiting the file but not Excel, so I added

application.displayalerts=false
application.quit

and now no matter how my users exit the file they won't see prompts asking
if they want to save. Thanks for the previous help.

"Merlynsdad" wrote:

The enableevents=false stops it from asking if I want to save the "real1.xls"
file, but I'm still getting a prompt asking if I want to save the
activeworkbook (mgrquery.xls) even with the me.saved=true. I need to kill
that prompt as well. And yes, I meant "beforeclose". Thanks.

"Dave Peterson" wrote:

Are you disabling events before you try to close the file with the code?

If no, then when that me.close line executes, it'll fire the
workbook_beforeClose event again (you meant _beforeclose, right???)

application.enableevents = false
Workbooks("real1.xls").Close False
Me.saved = true 'this will stop the "save?" prompt
'if you closed it, then the procedure would stop at that line
'(when the Me closes)
'and never get to this next line.
application.enableevents = true


Merlynsdad wrote:

I'm a problem closing a workbook without saving it. I'm closing another
workbook, then the current workbook with the following code in Private Sub
workbook_close():

Workbooks("real1.xls").Close False
Me.Close False

When I step through the code or run the code from the debug toolbar this
works. But when I use File Exit or the X, it asks whether or not I want to
save both files. I don't want to save either. What am I doing wrong?

--

Dave Peterson
.


--

Dave Peterson
.

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
Code only works in Debug mode. Why? Ayo Excel Programming 6 October 21st 09 04:04 PM
UDF Works in Debug Window but not on Sheet? Andibevan Excel Programming 2 September 26th 06 11:42 AM
Works fine in debug, but... DiBaco Excel Programming 5 February 24th 06 04:35 PM
Macro Works but not in Debug Step mode Bob Smedley[_2_] Excel Programming 3 January 31st 06 04:28 PM
Excel 2000 Code works except in debug mode Bob Smedley Excel Programming 0 January 24th 06 01:21 AM


All times are GMT +1. The time now is 08:22 PM.

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"