![]() |
Excel 2007 Craches when closing via macro code
When i close a workbook through code such as :
sub button6() Application.DisplayAlerts = False ActiveWorkbook.Save ActiveWorkbook.Close Application.DisplayAlerts = True End Sub and Private Sub Workbook_BeforeClose(Cancel As Boolean) On Error Resume Next Dim WB As Workbook For Each WB In Application.Workbooks Debug.Print WB.Name If WB.Name < ThisWorkbook.Name Then If WB.Windows(1).Visible = True Then Exit Sub End If Next Sheets("Navigation Sheet").Select Application.Quit End Sub I get an ERROR, prompts me to \send report to MS or not. If i open Excel and a blank sheet and then exit excel i get No error, so it seem to be ONLY when exiting via code. How do i fix this? Corey.... |
Excel 2007 Craches when closing via macro code
Give something like this a try...
Sub button6() Application.DisplayAlerts = False ActiveWorkbook.Save Application.Quit End Sub "Corey" wrote in message ... When i close a workbook through code such as : sub button6() Application.DisplayAlerts = False ActiveWorkbook.Save ActiveWorkbook.Close Application.DisplayAlerts = True End Sub and Private Sub Workbook_BeforeClose(Cancel As Boolean) On Error Resume Next Dim WB As Workbook For Each WB In Application.Workbooks Debug.Print WB.Name If WB.Name < ThisWorkbook.Name Then If WB.Windows(1).Visible = True Then Exit Sub End If Next Sheets("Navigation Sheet").Select Application.Quit End Sub I get an ERROR, prompts me to \send report to MS or not. If i open Excel and a blank sheet and then exit excel i get No error, so it seem to be ONLY when exiting via code. How do i fix this? Corey.... |
Excel 2007 Craches when closing via macro code
In article ,
"Corey" wrote: When i close a workbook through code such as : ActiveWorkbook.Close I get an ERROR, prompts me to \send report to MS or not. Have you installed the service pack that came out last week? One of the bugs fixed could be paraphrased as "legit VBA code that worked fine in Excel 2003 caused nonsensical crashes in Excel 2007 until we fixed it a year later with this service pack". I had similar crashes using the line you mention (though not every time it was invoked, or in every place it existed in the code) until last week's upgrade. -- David J Richardson -- http://davidj.richardson.name/ - Dr Who articles/interviews/reviews http://www.boomerang.org.au/ - Boomerang Association of Australia |
Excel 2007 Craches when closing via macro code
David J Richardson wrote:
In article , "Corey" wrote: When i close a workbook through code such as : ActiveWorkbook.Close I get an ERROR, prompts me to \send report to MS or not. Have you installed the service pack that came out last week? One of the bugs fixed could be paraphrased as "legit VBA code that worked fine in Excel 2003 caused nonsensical crashes in Excel 2007 until we fixed it a year later with this service pack". I had similar crashes using the line you mention (though not every time it was invoked, or in every place it existed in the code) until last week's upgrade. I've had a lot of these kind of crashes, so I'm hoping SP1 fixes it. Another thing I've seen: with a workbook with lots of macros open, and the VBE open, I can walk away, leave it doing nothing, and return to find it has crashed ("Do you Excel to attempt to recover your work?"). This doesn't happen if I don't have the VBE open. Has anyone seen anything like this, and does SP1 fix it? Thanks, Darren |
All times are GMT +1. The time now is 10:46 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com