Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Disable save/saveas dialog box upon closing

I saw another topic on this where the user wanted to automatically
save. I have macros running that disable saving and want the dialog
box not to automatically pop-up as the save button on it doesn't work
anyway.

I was trying all kinds of code such as:

Sub Auto_Close()
WorkbookObject.Saved = True
WorkbookObject.Close
End Sub

I also tried:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Cancel = True
End Sub


Still, when I close the application, I get the box asking if I would
like to save changes. How do I keep this box from automatically
popping up? I searched other answers and saw that they recommended
code that automatically saved it, but that is different. I thought I
would be able to simply adjust the code, but I couldn't figure that
out.

Also, I am using ThisWorkbook as I imagine that is the right place for
such code. Please correct me if I am wrong. Thank you.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 178
Default Disable save/saveas dialog box upon closing

On May 3, 11:50*am, Schatzi wrote:
I saw another topic on this where the user wanted to automatically
save. I have macros running that disable saving and want the dialog
box not to automatically pop-up as the save button on it doesn't work
anyway.

I was trying all kinds of code such as:

Sub Auto_Close()
WorkbookObject.Saved = True
WorkbookObject.Close
End Sub

I also tried:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Cancel = True
End Sub

Still, when I close the application, I get the box asking if I would
like to save changes. How do I keep this box from automatically
popping up? I searched other answers and saw that they recommended
code that automatically saved it, but that is different. I thought I
would be able to simply adjust the code, but I couldn't figure that
out.

Also, I am using ThisWorkbook as I imagine that is the right place for
such code. Please correct me if I am wrong. Thank you.



set enable events to false
Application.EnableEvents = False
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Disable save/saveas dialog box upon closing

Try...

Sub Auto_Close()
Application.DisplayAlerts = False
With WorkbookObject
.Saved = True: .Close
End With
Application.DisplayAlerts = True
End Sub

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 178
Default Disable save/saveas dialog box upon closing

On May 3, 11:52*am, Matthew Dyer wrote:
On May 3, 11:50*am, Schatzi wrote:





I saw another topic on this where the user wanted to automatically
save. I have macros running that disable saving and want the dialog
box not to automatically pop-up as the save button on it doesn't work
anyway.


I was trying all kinds of code such as:


Sub Auto_Close()
WorkbookObject.Saved = True
WorkbookObject.Close
End Sub


I also tried:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Cancel = True
End Sub


Still, when I close the application, I get the box asking if I would
like to save changes. How do I keep this box from automatically
popping up? I searched other answers and saw that they recommended
code that automatically saved it, but that is different. I thought I
would be able to simply adjust the code, but I couldn't figure that
out.


Also, I am using ThisWorkbook as I imagine that is the right place for
such code. Please correct me if I am wrong. Thank you.


set enable events to false
Application.EnableEvents = False- Hide quoted text -

- Show quoted text -


oops, got mixed up. it's actually display alerts.. not enable events.

Application.DisplayAlerts = False
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Disable save/saveas dialog box upon closing

On May 3, 1:58*pm, Matthew Dyer wrote:
On May 3, 11:52*am, Matthew Dyer wrote:





On May 3, 11:50*am, Schatzi wrote:


I saw another topic on this where the user wanted to automatically
save. I have macros running that disable saving and want the dialog
box not to automatically pop-up as the save button on it doesn't work
anyway.


I was trying all kinds of code such as:


Sub Auto_Close()
WorkbookObject.Saved = True
WorkbookObject.Close
End Sub


I also tried:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Cancel = True
End Sub


Still, when I close the application, I get the box asking if I would
like to save changes. How do I keep this box from automatically
popping up? I searched other answers and saw that they recommended
code that automatically saved it, but that is different. I thought I
would be able to simply adjust the code, but I couldn't figure that
out.


Also, I am using ThisWorkbook as I imagine that is the right place for
such code. Please correct me if I am wrong. Thank you.


set enable events to false
Application.EnableEvents = False- Hide quoted text -


- Show quoted text -


oops, got mixed up. it's actually display alerts.. not enable events.

Application.DisplayAlerts = False- Hide quoted text -

- Show quoted text -


I had already tried Application.DisplayAlerts = False

I just now inserted the code by GS and it is still not working. When I
click the "x" to close the workbook, the message still pops up asking
if I would like to save changes. I put the code exactly like GS had
into ThisWorkbook. Any ideas of what I can be doing wrong?


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 621
Default Disable save/saveas dialog box upon closing

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Me.Saved = True
End Sub

Will close without saving or asking.

NOTE: after inserting code you must save the workbook once.


Gord Dibben MS Excel MVP


On Tue, 3 May 2011 11:50:44 -0700 (PDT), Schatzi
wrote:

I saw another topic on this where the user wanted to automatically
save. I have macros running that disable saving and want the dialog
box not to automatically pop-up as the save button on it doesn't work
anyway.

I was trying all kinds of code such as:

Sub Auto_Close()
WorkbookObject.Saved = True
WorkbookObject.Close
End Sub

I also tried:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Cancel = True
End Sub


Still, when I close the application, I get the box asking if I would
like to save changes. How do I keep this box from automatically
popping up? I searched other answers and saw that they recommended
code that automatically saved it, but that is different. I thought I
would be able to simply adjust the code, but I couldn't figure that
out.

Also, I am using ThisWorkbook as I imagine that is the right place for
such code. Please correct me if I am wrong. Thank you.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Disable save/saveas dialog box upon closing

On May 3, 1:58*pm, Matthew Dyer wrote:
On May 3, 11:52*am, Matthew Dyer wrote:





On May 3, 11:50*am, Schatzi wrote:


I saw another topic on this where the user wanted to automatically
save. I have macros running that disable saving and want the dialog
box not to automatically pop-up as the save button on it doesn't work
anyway.


I was trying all kinds of code such as:


Sub Auto_Close()
WorkbookObject.Saved = True
WorkbookObject.Close
End Sub


I also tried:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Cancel = True
End Sub


Still, when I close the application, I get the box asking if I would
like to save changes. How do I keep this box from automatically
popping up? I searched other answers and saw that they recommended
code that automatically saved it, but that is different. I thought I
would be able to simply adjust the code, but I couldn't figure that
out.


Also, I am using ThisWorkbook as I imagine that is the right place for
such code. Please correct me if I am wrong. Thank you.


set enable events to false
Application.EnableEvents = False- Hide quoted text -


- Show quoted text -


oops, got mixed up. it's actually display alerts.. not enable events.

Application.DisplayAlerts = False- Hide quoted text -

- Show quoted text -


I tried the code by GS. I copied it exactly as it is into
ThisWorkbook, but it doesn't work. After making changes, I clicked the
top right "x" to close the application and the box popped up asking if
I would like to save changes. Any ideas of what I can be doing wrong?
Thanks.
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Disable save/saveas dialog box upon closing

On May 3, 2:08*pm, Gord Dibben wrote:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
* * Me.Saved = True
End Sub

Will close without saving or asking.

NOTE: after inserting code you must save the workbook once.

Gord Dibben * * MS Excel MVP

On Tue, 3 May 2011 11:50:44 -0700 (PDT), Schatzi
wrote:



I saw another topic on this where the user wanted to automatically
save. I have macros running that disable saving and want the dialog
box not to automatically pop-up as the save button on it doesn't work
anyway.


I was trying all kinds of code such as:


Sub Auto_Close()
WorkbookObject.Saved = True
WorkbookObject.Close
End Sub


I also tried:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Cancel = True
End Sub


Still, when I close the application, I get the box asking if I would
like to save changes. How do I keep this box from automatically
popping up? I searched other answers and saw that they recommended
code that automatically saved it, but that is different. I thought I
would be able to simply adjust the code, but I couldn't figure that
out.


Also, I am using ThisWorkbook as I imagine that is the right place for
such code. Please correct me if I am wrong. Thank you.- Hide quoted text -


- Show quoted text -


Gordon, I just put in your code and it worked perfect. Thank you all
for the replies.
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Disable save/saveas dialog box upon closing

After serious thinking Schatzi wrote :
On May 3, 1:58*pm, Matthew Dyer wrote:
On May 3, 11:52*am, Matthew Dyer wrote:





On May 3, 11:50*am, Schatzi wrote:
I saw another topic on this where the user wanted to automatically
save. I have macros running that disable saving and want the dialog
box not to automatically pop-up as the save button on it doesn't work
anyway.


I was trying all kinds of code such as:
Sub Auto_Close()
WorkbookObject.Saved = True
WorkbookObject.Close
End Sub


I also tried:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Cancel = True
End Sub


Still, when I close the application, I get the box asking if I would
like to save changes. How do I keep this box from automatically
popping up? I searched other answers and saw that they recommended
code that automatically saved it, but that is different. I thought I
would be able to simply adjust the code, but I couldn't figure that
out.


Also, I am using ThisWorkbook as I imagine that is the right place for
such code. Please correct me if I am wrong. Thank you.
set enable events to false
Application.EnableEvents = False- Hide quoted text -
- Show quoted text -


oops, got mixed up. it's actually display alerts.. not enable events.

Application.DisplayAlerts = False- Hide quoted text -

- Show quoted text -


I had already tried Application.DisplayAlerts = False

I just now inserted the code by GS and it is still not working. When I
click the "x" to close the workbook, the message still pops up asking
if I would like to save changes. I put the code exactly like GS had
into ThisWorkbook. Any ideas of what I can be doing wrong?


Perhaps your WorkbookObject var was not holding a fully qualified ref
to the wkb being closed. Otherwise, the code I posted worked for the
file I tested it with.

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Disable save/saveas dialog box upon closing

Another approach to closing without saving (and thus not raising the
alert) is...

WorkbookObject.Close SaveChanges:=False

Of course, 'WorkbookObject' still requires a fully qualified ref be
'Set' to the workbook being closed.

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc




  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Disable save/saveas dialog box upon closing

On May 3, 3:29*pm, GS wrote:
Another approach to closing without saving (and thus not raising the
alert) is...

* WorkbookObject.Close SaveChanges:=False

Of course, 'WorkbookObject' still requires a fully qualified ref be
'Set' to the workbook being closed.

--
Garry

Free usenet access athttp://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


I don't know what you mean by fully qualified reference. I imagine
that since I do not know what that means, I must not have done that
correctly.
  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Disable save/saveas dialog box upon closing

Schatzi has brought this to us :
On May 3, 3:29*pm, GS wrote:
Another approach to closing without saving (and thus not raising the
alert) is...

* WorkbookObject.Close SaveChanges:=False

Of course, 'WorkbookObject' still requires a fully qualified ref be
'Set' to the workbook being closed.

--
Garry

Free usenet access athttp://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


I don't know what you mean by fully qualified reference. I imagine
that since I do not know what that means, I must not have done that
correctly.


Your code suggests that 'WorkbookObject' refs a specific open workbook,
and so this object variable should have been initialized at some point
elsewhere in your code using the 'Set' statement something like...

Set WorkbookObject = Workbooks("Filename.xls")

Otherwise, 'WorkbookObject' means nothing to VBA.

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


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
How can just opening & closing a workbook prompt the Save? dialog? [email protected] Excel Programming 4 May 26th 08 08:40 PM
disable save as dialog box Dion Excel Programming 2 October 5th 06 09:11 PM
disable save and saveas from menubar and save via command button Steve E Excel Programming 5 September 13th 06 11:51 PM
closing read-only without save dialog box appearing JNW Excel Programming 0 December 28th 05 03:14 PM
Disable Saveas Dialog Tom Ogilvy Excel Programming 0 September 15th 04 05:41 PM


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