Ah, I think...
Duplicates was with reference to comparing names (strings) You can't have
two workbooks open with the same name.
I believe Is should work as you intend - however in xl97 there was no
guarantee that it would and there was a KB that advised against using that
syntax for that purpose. I believe it works ok in later versions, but can't
speak authoritatively.
Regards,
Tom Ogilvy
Arne wrote in message
...
I was thinking of using a fixed name (variable or const
string). I agree, that would be one of the worst ways to
do it.
What do you mean by duplicates, Tom? I hope that the Is
operator compares the (memory location of) the objects,
and that it returns false when it is used to compare two
different instances of the same class, even if they are
duplicates. This is what I understand from the help file
on this operator, but if this is not the case, I think I
have to do some code checking.
If the Is operator works the way I hope it does, I would
prefer comparing the objects instead of one of their
properties.
-----Original Message-----
Since there is nothing in the macro that specifically
maximizes the
workbook, this must be an inherent action of the close
method. You can
avoid seeing it and perhaps this will speed up your macro
Dim wkb As Workbook
Application.DisplayAlerts = False
Application.ScreenUpdating = False
For Each wkb In Workbooks
If Not wkb.Name = ThisWorkbook.Name Then
wkb.Close SaveChanges:=False
End If
Next wkb
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Also shows how you can use the Name - no danger of
duplicates - you can't
have a duplicate name. Also, needs no adjustment if you
rename the
workbook. Not sure what Arne was thinking of.
Regards,
Tom Ogilvy
"jonas" wrote in message
...
Hi
yes that solution I know of but it is not applicable for
me right now since I have 7500 files to process and they
are all named differently.
Another thing I thought of is if it would be possible to
close all open but minimised workbooks without maximase
them? Right now I have 17 open workbooks which are all
minimised and with changes which I would like to close
without saving any changes. The macro you sent me works
fine but it maximise every workbook before closing it
which takes some time. Closing without saving changes
and
without maximising the windows would probably go faster.
Do you know if there is such a solution?
Kind regards
Jonas
-----Original Message-----
By the way, as always there are several possible
solutions
o the problem. Instead of comparing the objects wkb and
ThisWorkbook (using the 'Is' operator), you could also
consider comparing wkb.Name with the name of your
workbook. However, in that case, you have to alter your
macro whenever you change the name of your workbook.
.
.
|