Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
XP XP is offline
external usenet poster
 
Posts: 389
Default Make file drop dead on close

Using Windows 2003 and Office XP;

I have the following in ThisWorkbook:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Cancel = True
Application.EnableEvents = False
Application.DisplayAlerts = False
ThisWorkbook.Close SaveChanges:=False
Application.DisplayAlerts = True
Application.EnableEvents = True
End Sub

I know that the alerts and the events are not likely switched back on since
they come after the close; however, this file is set to open "Read Only" by
default (file attribute) and I cannot get this thing to close without a "Do
you want to save" message. I want the file to drop dead on close: i.e. no
warnings, no questions asked, no save.

How can I get this to work?
Thanks much in advance for your assistance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 227
Default Make file drop dead on close

Put this in the This Workbook module:

Private Sub Workbook_BeforeClose(Cancel As Boolean)

ThisWorkbook.Saved = True

End Sub

That should do it.

Mark Lincoln

On Nov 8, 3:21 pm, XP wrote:
Using Windows 2003 and Office XP;

I have the following in ThisWorkbook:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Cancel = True
Application.EnableEvents = False
Application.DisplayAlerts = False
ThisWorkbook.Close SaveChanges:=False
Application.DisplayAlerts = True
Application.EnableEvents = True
End Sub

I know that the alerts and the events are not likely switched back on since
they come after the close; however, this file is set to open "Read Only" by
default (file attribute) and I cannot get this thing to close without a "Do
you want to save" message. I want the file to drop dead on close: i.e. no
warnings, no questions asked, no save.

How can I get this to work?
Thanks much in advance for your assistance.



  #3   Report Post  
Posted to microsoft.public.excel.programming
XP XP is offline
external usenet poster
 
Posts: 389
Default Make file drop dead on close

Hi Mark,

Sorry, but this doesn't work...

Now my file also runs hidden, so I don't know if that is a new wrinkle or
not. This did work for another file, that my problem file opened, but not the
main problem file that runs hidden.

Any other ideas?

"Mark Lincoln" wrote:

Put this in the This Workbook module:

Private Sub Workbook_BeforeClose(Cancel As Boolean)

ThisWorkbook.Saved = True

End Sub

That should do it.

Mark Lincoln

On Nov 8, 3:21 pm, XP wrote:
Using Windows 2003 and Office XP;

I have the following in ThisWorkbook:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Cancel = True
Application.EnableEvents = False
Application.DisplayAlerts = False
ThisWorkbook.Close SaveChanges:=False
Application.DisplayAlerts = True
Application.EnableEvents = True
End Sub

I know that the alerts and the events are not likely switched back on since
they come after the close; however, this file is set to open "Read Only" by
default (file attribute) and I cannot get this thing to close without a "Do
you want to save" message. I want the file to drop dead on close: i.e. no
warnings, no questions asked, no save.

How can I get this to work?
Thanks much in advance for your assistance.




  #4   Report Post  
Posted to microsoft.public.excel.programming
XP XP is offline
external usenet poster
 
Posts: 389
Default Make file drop dead on close

Hello again,

Now it seems to be working; I'm not sure why it didn't at first...maybe it
just need to burn in or something...

Anyway thanks!

If anyone else has anything to add on this issue, I welcome your comments...

"Mark Lincoln" wrote:

Put this in the This Workbook module:

Private Sub Workbook_BeforeClose(Cancel As Boolean)

ThisWorkbook.Saved = True

End Sub

That should do it.

Mark Lincoln

On Nov 8, 3:21 pm, XP wrote:
Using Windows 2003 and Office XP;

I have the following in ThisWorkbook:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Cancel = True
Application.EnableEvents = False
Application.DisplayAlerts = False
ThisWorkbook.Close SaveChanges:=False
Application.DisplayAlerts = True
Application.EnableEvents = True
End Sub

I know that the alerts and the events are not likely switched back on since
they come after the close; however, this file is set to open "Read Only" by
default (file attribute) and I cannot get this thing to close without a "Do
you want to save" message. I want the file to drop dead on close: i.e. no
warnings, no questions asked, no save.

How can I get this to work?
Thanks much in advance for your assistance.




  #5   Report Post  
Posted to microsoft.public.excel.programming
XP XP is offline
external usenet poster
 
Posts: 389
Default Make file drop dead on close

Hello again,

I was wrong! This method only works if the file property is set to not read
only!

Once set to open read only, it fails and still prompts me about saving...
any other ideas?

"XP" wrote:

Hello again,

Now it seems to be working; I'm not sure why it didn't at first...maybe it
just need to burn in or something...

Anyway thanks!

If anyone else has anything to add on this issue, I welcome your comments...

"Mark Lincoln" wrote:

Put this in the This Workbook module:

Private Sub Workbook_BeforeClose(Cancel As Boolean)

ThisWorkbook.Saved = True

End Sub

That should do it.

Mark Lincoln

On Nov 8, 3:21 pm, XP wrote:
Using Windows 2003 and Office XP;

I have the following in ThisWorkbook:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Cancel = True
Application.EnableEvents = False
Application.DisplayAlerts = False
ThisWorkbook.Close SaveChanges:=False
Application.DisplayAlerts = True
Application.EnableEvents = True
End Sub

I know that the alerts and the events are not likely switched back on since
they come after the close; however, this file is set to open "Read Only" by
default (file attribute) and I cannot get this thing to close without a "Do
you want to save" message. I want the file to drop dead on close: i.e. no
warnings, no questions asked, no save.

How can I get this to work?
Thanks much in advance for your assistance.






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 227
Default Make file drop dead on close

The code works for me on a read-only file. Did you put the code in
the ThisWorkbook module in the read-only file? And did you remove the
read-only restriction before entering the code, then reset the file to
read-only?

Mark Lincoln

On Nov 8, 4:52 pm, XP wrote:
Hello again,

I was wrong! This method only works if the file property is set to not read
only!

Once set to open read only, it fails and still prompts me about saving...
any other ideas?



"XP" wrote:
Hello again,


Now it seems to be working; I'm not sure why it didn't at first...maybe it
just need to burn in or something...


Anyway thanks!


If anyone else has anything to add on this issue, I welcome your comments...


"Mark Lincoln" wrote:


Put this in the This Workbook module:


Private Sub Workbook_BeforeClose(Cancel As Boolean)


ThisWorkbook.Saved = True


End Sub


That should do it.


Mark Lincoln


On Nov 8, 3:21 pm, XP wrote:
Using Windows 2003 and Office XP;


I have the following in ThisWorkbook:


Private Sub Workbook_BeforeClose(Cancel As Boolean)
Cancel = True
Application.EnableEvents = False
Application.DisplayAlerts = False
ThisWorkbook.Close SaveChanges:=False
Application.DisplayAlerts = True
Application.EnableEvents = True
End Sub


I know that the alerts and the events are not likely switched back on since
they come after the close; however, this file is set to open "Read Only" by
default (file attribute) and I cannot get this thing to close without a "Do
you want to save" message. I want the file to drop dead on close: i.e. no
warnings, no questions asked, no save.


How can I get this to work?
Thanks much in advance for your assistance.- Hide quoted text -


- Show quoted text -


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
Everytime i close an excel file, it creates a new backup file p Excel Discussion (Misc queries) 3 November 22nd 07 08:13 AM
Can we make Excel close itself without asking anything? Andrew Excel Programming 2 March 8th 07 08:19 PM
Macro to make excel close grandfilth Excel Programming 5 October 20th 05 05:20 PM
VBA - on a button event, open another closed file, post changes, close file Fio Excel Programming 0 March 1st 04 01:08 PM
Automate open file, update links, run macro, close and save file Geoff[_7_] Excel Programming 2 August 26th 03 10:13 PM


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