LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Closing files by a macro

Kurt,
Not sure why you have loop with Dir() if you are closing workbooks...
The "normal" way would be :

Dim WS As Workbook

For Each WS In Workbooks
If WS.Name < ThisWorkbook.Name Then WS.Close SaveChanges:=True
Next

But it depends somewhat on where you are running this code.

NickHK

"kurt" wrote in message
oups.com...
Hi all

This macro is closing a numbers of workbooks as fast as i can.

Private Sub Closeall()
On Error Resume Next
f = Dir(CurDir & "\", 7)
Do While f < ""
f = Dir
.
. here you can chek for read only files
. here you can close all sheets.

ActiveWorkbook.Close savechanges:=True
Loop
End Sub


regards

Kurt

Die_Another_Day skrev:

np glad to help :)

charles

JLGWhiz wrote:
I stand corrected. tnx Chs.

"Die_Another_Day" wrote:

JLG, The syntax for Close is:
ActiveWorkbook.Close SaveChanges:=True
So the " True" takes care of the save.

Charles

JLGWhiz wrote:
You might want to throw in : ActiveWorkbook.Save : in Charles'

code to save
and close.

"Die_Another_Day" wrote:

Dim wb as Workbook
For each wb in Workbooks
if not wb.name = "Personal.xls" Then
wb.Close True
End if
next

Is that what you are trying to accomplish?

Charles

kurt wrote:
Hi all


I have 20 excellworkbooks open with diferent names.

Problem is to save and close theese files as fast as possible

by a
macro.

As it is now, one file has to be saved and closed before I can

run the
macro again manually.
Is the a vbariable there can be used to automatic restart the

macro???

anyone have an idea??


The macro is placed in Personal.xls.



regards


kurt







 
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 all files colt Excel Programming 4 August 23rd 06 01:30 PM
Closing files and saving files dan Excel Worksheet Functions 0 August 15th 06 04:07 AM
Save files before closing MasterP Excel Discussion (Misc queries) 1 December 30th 05 08:13 PM


All times are GMT +1. The time now is 02:14 PM.

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"