Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Saving VBA project on workbook close

Sorry if this is an obvious one. I want to have code to protect myself from
closing a project without saving changes. The code below just doesn't execute
the save although the logic hits the line.

TIA, Eric

in Thisworkbook

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Cancel = Not Shutdown(ThisWorkbook)
If Cancel Then
Call ThisWorkbook.Save
Debug.Assert ThisWorkbook.Saved
Cancel = False
End If
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Saving VBA project on workbook close

Eric,
What is Shutdown ?

NickHK

"Eric Fingerhut" wrote in message
...
Sorry if this is an obvious one. I want to have code to protect myself

from
closing a project without saving changes. The code below just doesn't

execute
the save although the logic hits the line.

TIA, Eric

in Thisworkbook

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Cancel = Not Shutdown(ThisWorkbook)
If Cancel Then
Call ThisWorkbook.Save
Debug.Assert ThisWorkbook.Saved
Cancel = False
End If
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 276
Default Saving VBA project on workbook close

Sub Macro1()
Application.DisplayAlerts = True
ActiveWorkbook.Save ' saves active workbook
Application.Quit ' exits Excel
End Sub


Corey....


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Saving VBA project on workbook close

Doesn't work for me, at least not in Workbook_BeforeClose

"Corey" wrote:

Sub Macro1()
Application.DisplayAlerts = True
ActiveWorkbook.Save ' saves active workbook
Application.Quit ' exits Excel
End Sub


Corey....



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Saving VBA project on workbook close

You need to provide more details if you want constructive help.
What are supposed to make of "Doesn't work for me" ?

NickHK

"EricF" wrote in message
...
Doesn't work for me, at least not in Workbook_BeforeClose

"Corey" wrote:

Sub Macro1()
Application.DisplayAlerts = True
ActiveWorkbook.Save ' saves active workbook
Application.Quit ' exits Excel
End Sub


Corey....





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
VBA project does not close when workbook is closed SimonN Excel Programming 5 July 1st 20 05:47 AM
VBA project does not close when workbook is closed Simon Norris Excel Programming 5 March 2nd 16 05:34 PM
close workbook without saving or promt to save ATVNSHANE Excel Discussion (Misc queries) 3 February 4th 10 03:57 PM
Close a workbook without saving macros Papa Jonah Excel Programming 12 October 27th 04 12:43 AM
VBA project does not close when workbook is closed SimonN Excel Programming 3 October 25th 04 09:23 PM


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