Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Auto_Close() not running

Got it!

As you can see below, the Auto_Close macro just calls a subroutine called
Luc_Auto_Close which is held in another module in the workbook.As coded,
this Luc_Auto_Close macro is called once regardless of how many workbooks I
have loaded.

When I moved the code from Luc_Auto_Close in to the Auto_Close sub,
everything started working properly again. Every workbook calls it's
Auto_Close macro and they all run to completion.

Not at all what I would have expected.

Steve


"Steve Barnett" wrote in message
...
I'm running this in Excel2003 also, so I'm very confused. As far as I can
see there is nothing in the code that would cause the other workbooks to
close. All I do is reset the changes I made to the menu and unprotect a
few sheets.

I guess I'll have to keep looking...

My Auto_Close contans:

sub Auto_Close()
Luc_Auto_Close
end Sub

Sub Luc_Auto_Close()
'***Restore default Excel menu bar
Application.Run macro:="ResetMenu"

'***Turn off screen updating during macro
Application.ScreenUpdating = False

'***Unprotect all worksheets
Sheets("Benefits reporting").Select
ActiveSheet.Unprotect
Sheets("Programme reporting").Select
ActiveSheet.Unprotect
Sheets("Costs reporting").Select
ActiveSheet.Unprotect
Sheets("TLB breakdown").Select
ActiveSheet.Unprotect
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Sheets(1).Activate
Range("A1").Select

'***Save workbook
ActiveWorkbook.Save

'***Turn on screen updating during macro
'Application.ScreenUpdating = True
End Sub


"Dave Peterson" wrote in message
...
I just tried this in xl2003 and auto_close ran for all the workbooks.

What version of excel are you running?

And do you have any code in the first auto_close that might be closing
the other
workbooks.

If you do, then you'll have to run that auto_close routine yourself.

There's a nice example in VBA's help -- look for RunAutoMacros.



Steve Barnett wrote:

I have three identical (bar the data) spreadsheets which get loaded at
the
same time. They all contain an auto_close() macro.

If I close all three spreadsheets, one at a time, then the auto_close()
macro runs in each spreadsheet, so allowing me to clean up properly and
allowing me to avoid the "do you want to save" prompt. However, if I
click
the close button for Excel, only one of the auto_close() macros runs.
The
other two spreadsheets prompt the user to save the file.

I've put break points in the auto_close() macros for all three
spreadsheets
and only one auto_close() is being run.

Anyone know whether this is by design or a bug and whether there is a
workaround for this behaviour?

Thanks
Steve


--

Dave Peterson





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
BeforeClose vs Auto_Close [email protected] Excel Programming 16 June 3rd 05 10:06 PM
question about Auto_Close and WorkbookBeforeClose Brian Murphy Excel Programming 8 October 9th 04 08:08 PM
Question about auto_close Neil[_20_] Excel Programming 3 July 7th 04 09:24 PM
Auto_Close() needs help Phil Hageman[_3_] Excel Programming 3 November 19th 03 05:56 PM
Auto_Close Luc Benninger Excel Programming 2 October 14th 03 12:34 PM


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