Wrox Programmer Forums
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 28th, 2004, 11:46 PM
Registered User
 
Join Date: Oct 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Close and Save errors

Hi All,

My macros allow me to operate my spreasheet correctly now until I try to save the amended file using my spreadsheet menu or using the Excel window close and save options.

If I close without saving (either method) all works OK and the file can be reopened with macros enabled.

If I use the window close and save options, after some delay I get the error message 'File not Saved'.

If I save using my spreadsheet menu (using the same file name)the file apparently saves but when I reopen the file all macros are disabled and Excel locks up.

If I shut down excel and reopen it and then open the file with the Auto open macro disabled and subsequently other macros disabled, and then save the file again (same name) and then reopen the file with macros enabled all works OK again.

Can anyone help please - I have copied the relevant VB code below.

Private Sub Workbook_Open()
Call Opener
End Sub


Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.CommandBars("Reviewing").Visible = False
Worksheets("Opening").Activate
Range("A1").Select
Call ResetMenu
Application.CommandBars("standard").Enabled = True
Application.CommandBars("formatting").Enabled = True
Application.CommandBars("View").Enabled = True
Application.CommandBars("Tools").Enabled = True
Application.CommandBars("File").Enabled = True
Application.DisplayFormulaBar = True
Worksheets("Assumptions").Visible = xlSheetVeryHidden
Worksheets("Graph").Visible = xlSheetVeryHidden
Worksheets("Supplement").Visible = xlSheetVeryHidden
Worksheets("Gsupplement").Visible = xlSheetVeryHidden
Worksheets("Summary").Visible = xlSheetVeryHidden
Worksheets("Maintenance").Visible = xlSheetVeryHidden
Worksheets("Growth").Visible = xlSheetVeryHidden
Worksheets("Drought").Visible = xlSheetVeryHidden
Worksheets("Breeder").Visible = xlSheetVeryHidden
Worksheets("GandM").Visible = xlSheetVeryHidden
Worksheets("Table").Visible = xlSheetVeryHidden
Application.DisplayCommentIndicator = xlCommentIndicatorOnly
Application.CommandBars("Reviewing").Visible = False
Application.ScreenUpdating = True
End Sub



' Opener Macro
'
'
Sub Opener()
Application.DisplayCommentIndicator = 0
Application.ScreenUpdating = False
Application.CommandBars("standard").Enabled = False
Application.CommandBars("formatting").Enabled = False
Application.DisplayFormulaBar = False
Application.CommandBars("View").Enabled = False
Application.CommandBars("Tools").Enabled = False
Application.CommandBars("File").Enabled = False
Call FlapMenu
Worksheets("Assumptions").Visible = True
Worksheets("Graph").Visible = True
Worksheets("Supplement").Visible = True
Worksheets("Gsupplement").Visible = True
Worksheets("Summary").Visible = True
Worksheets("Maintenance").Visible = True
Worksheets("Growth").Visible = True
Worksheets("Drought").Visible = True
Worksheets("Breeder").Visible = True
Worksheets("GandM").Visible = True
Worksheets("Table").Visible = True
Application.ScreenUpdating = True
End Sub


' Closer Macro
'
'
Sub Closer()

Dim iReply As Integer

iReply = MsgBox("Close Save Changes or Close Without Saving Changes or Cancel and Return to Deer Feeding", vbYesNoCancel)
Select Case iReply
Case vbYes
ActiveWorkbook.Close True
Case vbNo
ActiveWorkbook.Close False
Case vbCancel
Call Opening
End Select
End Sub







Similar Threads
Thread Thread Starter Forum Replies Last Post
Open Workbook,Copy Sheet,Move Sheet, Close/Save ptrussell2009 Excel VBA 0 June 13th, 2008 02:28 PM
Browser close when screen saver close Rehanrana Pro VB 6 1 April 7th, 2008 03:09 AM
Report prompts to save changes on close srcLakeJake Access 3 January 4th, 2008 09:16 AM
window.close() failing to...well...close! mheathcote Javascript How-To 2 October 31st, 2005 03:02 PM
Can't get errors to display with <html:errors> michaeldill JSP Basics 0 August 2nd, 2004 01:47 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.