Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 363
Default 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....



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default 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....



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default 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

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
Why doesn't Excel 2007 record charting and office art macro code? NOLuckMatt Excel Discussion (Misc queries) 0 August 17th 07 02:38 PM
How to code on Macro on saving and closing a file? Eric Excel Worksheet Functions 1 June 10th 07 01:32 PM
CLosing Excel 2007 with personal macro workbook Kato Wilbur Excel Discussion (Misc queries) 3 March 13th 07 09:59 PM
Macro Code for closing excel... Bonbon[_4_] Excel Programming 5 April 12th 06 12:57 PM
Changing VBE WS-component name in code craches excel 97 Nick Dreyer Excel Programming 5 December 5th 05 08:48 AM


All times are GMT +1. The time now is 06:40 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"