Check for other open workbooks
Thanks
here is my test code based on your reply: But I get an Invalid use of
Property error and it highlights .Count
Sub test()
Application.Workbooks.Count
If Application.Workbooks.Count = 0 Then
Application.Quit
End
End If
ThisWorkbook.Close False
End Sub
"Gord Dibben" <gorddibbATshawDOTca wrote in message
...
Application.Workbooks.Count
If more than 1 then close current WB only
If only 1 then close WB and Application.Quit
Gord Dibben MS Excel MVP
On Wed, 28 Apr 2010 14:57:10 -0700, "ordnance1"
wrote:
Thanks.
That will close the active workbook but I need to close Excel only if
there
are no other workbooks open.
"Suri" wrote in message
...
On Apr 28, 10:30 pm, "ordnance1" wrote:
I was using the line below at the end of my code and all was well.
Until
someone had other Excel workbooks open (besides the one I had created)
and
the code ran doing what it was supposed to do and closed excel
completely. I
do want the Excel to close down, but only if my workbook is the only
workbook open.
So is there any way to amend what I have to check for other open
workbooks,
and if there are any open the just close my workbook only?
Application.Quit
Try
Application.ActiveWorkbook.Close(SaveChanges:=Fals e)
|