View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
colt colt is offline
external usenet poster
 
Posts: 5
Default closing all files

thanks Muhammed
this code works well
many thanks for your response
I have now overcome a hurdle in my application which has taken some time.
regards colt

"Muhammed Rafeek M" wrote:

try this macro

Sub CloseAllWorkbook()
Dim i As Integer
For i = Workbooks.Count To 1 Step -1
If ThisWorkbook.Name < Workbooks(i).Name Then
Workbooks(i).Close
End If
Next i
End Sub


"Jean-Yves" wrote:

HI,

Keep shift key pressed, menu File/Close all
or
Private Sub Workbook_BeforeClose(Cancel As Boolean)

dim wb as workbook
for each wb in workbooks
if wb.name < thisworkbook.namen then wb.close False 'close without save
next
End Sub

Put this in the Thisworkbook module
Regards
JY

"colt" wrote in message
...
how can i close all open office files as i close current active workbook?