View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Mike Fogleman Mike Fogleman is offline
external usenet poster
 
Posts: 1,092
Default Check for open workbooks

You will need to trap for the Personal.xls workbook which will always be
open if the user has one.

Sub CountWBOpen()
Dim wb As Workbook
Dim x As Integer

x = Workbooks.Count
For Each wb In Workbooks
If wb.name = "Personal.xls" Then
x = x - 1
End If
Next
If x 1 Then
MsgBox ("more than 1")
Exit Sub
Else
MsgBox ("only 1")
End If
End Sub

Mike F
"Stephen C" wrote in message
...
How do i check to find out if any other workbooks are open?

I need to do this check in a macro therefore require the VBA code.

I have a workbook with a macro in, when a user runs this macro i need it
to
check to see if any other workbooks are open. This macro will not run
correctly if others are open.

I am using Office 2000 - SP3