Macro update
Tom, thanks for your suggestion. It works purrrfecly, even does something
that I had forgot to mention! Thanks to Bob and Nigel as well. Nigel I
didn't get yours in time to try it as Tom's macro was very good.
Regards to all,
Roger
"Nigel" wrote in message
...
Workbooks count will return the count of open workbooks hidden or
otherwsie.
So just us the following. However place the code in the personal book or
the last book to close, else the macro will terminate early!
Sub test()
Dim Index As Integer
For Index = 1 To Application.Workbooks.Count
ActiveWorkbook.Close saveChanges:=True
Next Index
Application.Quit
End Sub
--
Cheers
Nigel
"Roger" wrote in message
...
I would like the following macro to shut down all open files including 1
hidden file and the shut down the Excel program. I have used this macro
for
many years in Excel 5. I am now upgrading to Excel 2002 where it doesn't
work. Do you have any suggestions as to what the problem could be?
Dim Index As Integer, Number As Integer, FinalNumber As Integer
'Index
is a loop counter
Number = Application.Workbooks.Count 'The Number of open Workbooks
FinalNumber = Number - 1 'The 1 refers to the
hidden file
For Index = 1 To FinalNumber 'Place the Workbook
names
in an array
ActiveWorkbook.Close saveChanges:=True
Next Index
Application.Quit
Thanks,
Roger
|