Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default closing all files

how can i close all open office files as i close current active workbook?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 253
Default closing all files

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?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 179
Default closing all files

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?




  #4   Report Post  
Posted to microsoft.public.excel.programming
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?




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

Hi Jean-Yves
thanks so much - i have been working on this problem for some time.
I needed the code version and I just got it to work - so excited.
kindest regards colt.

"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?






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
Closing Files CLASSC Excel Discussion (Misc queries) 1 November 2nd 09 06:05 PM
Closing Files Diana Heimberger Excel Discussion (Misc queries) 3 September 1st 06 06:45 PM
Closing files and saving files dan Excel Worksheet Functions 0 August 15th 06 04:07 AM
Closing Files and Reopening them in VBA VBAQuest Excel Programming 1 November 17th 05 02:52 PM
Closing files without save Warren Excel Programming 5 February 5th 04 09:58 AM


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